Skip to content

Commit

Permalink
Merge in changes since first attempt at subtrees
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Feb 11, 2025
1 parent da4456f commit 8a51004
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/core/nettlesome.EmailAddress.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import anticipation.*
import contextual.*
import contingency.*
import denominative.*
import distillate.*
import fulminate.*
import gossamer.*
import hypotenuse.*
Expand Down
9 changes: 3 additions & 6 deletions src/core/nettlesome.Nettlesome.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package nettlesome

import anticipation.*
import contingency.*
import distillate.*
import fulminate.*
import gossamer.*
import hieroglyph.*, textMetrics.uniform
Expand Down Expand Up @@ -128,9 +129,7 @@ object Nettlesome:
given encodable: TcpPort is Encodable in Text = port => TextConversion.int.text(port.number)

given decoder: (Tactic[NumberError], Tactic[PortError]) => TcpPort is Decodable in Text =
text =>
import Decoder.int
apply(text.decode[Int])
text => apply(text.decode[Int])

def unsafe(value: Int): TcpPort = value.asInstanceOf[TcpPort]

Expand All @@ -143,7 +142,7 @@ object Nettlesome:
given encodable: UdpPort is Encodable in Text = port => TextConversion.int.text(port.number)

given decoder: (Tactic[NumberError], Tactic[PortError]) => UdpPort is Decodable in Text =
text => apply(Decoder.int.decoded(text))
text => apply(text.decode[Int])

def unsafe(value: Int): UdpPort = value.asInstanceOf[UdpPort]

Expand Down Expand Up @@ -186,15 +185,13 @@ object Nettlesome:

def tcpPort(context: Expr[StringContext])(using Quotes): Expr[TcpPort] =
val portNumber: Int =
import Decoder.int
haltingly(context.valueOrAbort.parts.head.tt.decode[Int])

if 1 <= portNumber <= 65535 then '{TcpPort.unsafe(${Expr(portNumber)})}
else halt(m"the TCP port number ${portNumber} is not in the range 1-65535")

def udpPort(context: Expr[StringContext])(using Quotes): Expr[UdpPort] =
val portNumber: Int =
import Decoder.int
haltingly(context.valueOrAbort.parts.head.tt.decode[Int])

if 1 <= portNumber <= 65535 then '{UdpPort.unsafe(${Expr(portNumber)})}
Expand Down
1 change: 1 addition & 0 deletions src/url/nettlesome.Url.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import anticipation.*
import contextual.*
import contingency.*
import denominative.*
import distillate.*
import escapade.*
import fulminate.*
import gossamer.*
Expand Down

0 comments on commit 8a51004

Please sign in to comment.