Skip to content

Commit

Permalink
Renamed msg"" to m""
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jul 1, 2024
1 parent 0a53dfa commit c784258
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/core/numbermacros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@ import scala.compiletime.*

object Cardinality:
given Realm = realm"cardinality"

def apply[LeftDoubleType <: Double: Type, RightDoubleType <: Double: Type](digits: Expr[String])(using Quotes)
: Expr[LeftDoubleType ~ RightDoubleType] =

import quotes.reflect.*

digits.value match
case Some(string) =>
TypeRepr.of[LeftDoubleType].asMatchable match
case ConstantType(DoubleConstant(lowerBound)) =>
TypeRepr.of[RightDoubleType].asMatchable match
case ConstantType(DoubleConstant(upperBound)) =>
val value = string.toDouble

if value < lowerBound
then abandon(msg"""the value $string is less than the lower bound for this value,
then abandon(m"""the value $string is less than the lower bound for this value,
${lowerBound.toString}""")

if value > upperBound
then abandon(msg"""the value $string is greater than the upper bound for this value,
then abandon(m"""the value $string is greater than the upper bound for this value,
${upperBound.toString}""")

'{${Expr(value)}.asInstanceOf[LeftDoubleType ~ RightDoubleType]}

case _ =>
abandon(msg"the upper bound must be a Double singleton literal types")
abandon(m"the upper bound must be a Double singleton literal types")
case _ =>
abandon(msg"the lower bound must be a Double singleton literal types")
abandon(m"the lower bound must be a Double singleton literal types")
case None =>
'{NumericRange($digits.toDouble)}

0 comments on commit c784258

Please sign in to comment.