Skip to content

Commit

Permalink
Rename abandonment to haltingly
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Dec 27, 2024
1 parent 2717ec8 commit 8e4de09
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/nettlesome.EmailAddress.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object EmailAddress:
given (using Tactic[EmailAddressError]) => Decoder[EmailAddress] = EmailAddress.parse(_)
given EmailAddress is Encodable in Text = _.text

def expand(context: Expr[StringContext])(using Quotes): Expr[EmailAddress] = abandonment:
def expand(context: Expr[StringContext])(using Quotes): Expr[EmailAddress] = haltingly:
val text: Text = context.valueOrAbort.parts.head.tt
val address = EmailAddress.parse(text)

Expand Down
2 changes: 1 addition & 1 deletion src/core/nettlesome.Hostname.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object Hostname:

given Hostname is Showable = _.dnsLabels.map(_.show).join(t".")

def expand(context: Expr[StringContext])(using Quotes): Expr[Hostname] = abandonment:
def expand(context: Expr[StringContext])(using Quotes): Expr[Hostname] = haltingly:
Expr(Hostname.parse(context.valueOrAbort.parts.head.tt))

given ToExpr[Hostname] as toExpr:
Expand Down
8 changes: 4 additions & 4 deletions src/core/nettlesome.Nettlesome.scala
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,21 @@ object Nettlesome:
case class Ipv6(highBits: Long, lowBits: Long)

def tcpPort(context: Expr[StringContext])(using Quotes): Expr[TcpPort] =
val portNumber: Int = abandonment(context.valueOrAbort.parts.head.tt.decode[Int])
val portNumber: 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 = abandonment(context.valueOrAbort.parts.head.tt.decode[Int])
val portNumber: Int = haltingly(context.valueOrAbort.parts.head.tt.decode[Int])

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

def ip(context: Expr[StringContext])(using Quotes): Expr[Ipv4 | Ipv6] =
val text = Text(context.valueOrAbort.parts.head)

abandonment:
haltingly:
if text.contains(t".") then
val ipv4 = Ipv4.parse(text)
'{Ipv4(${Expr(ipv4.byte0)}, ${Expr(ipv4.byte1)}, ${Expr(ipv4.byte2)}, ${Expr(ipv4.byte3)})}
Expand All @@ -204,7 +204,7 @@ object Nettlesome:
val ipv6 = Ipv6.parse(text)
'{Ipv6(${Expr(ipv6.highBits)}, ${Expr(ipv6.lowBits)})}

def mac(context: Expr[StringContext])(using Quotes): Expr[MacAddress] = abandonment:
def mac(context: Expr[StringContext])(using Quotes): Expr[MacAddress] = haltingly:
val macAddress = MacAddress.parse(context.valueOrAbort.parts.head.tt)
'{MacAddress(${Expr(macAddress.long)})}

Expand Down

0 comments on commit 8e4de09

Please sign in to comment.