Skip to content

Commit

Permalink
Updates for Scala 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jan 19, 2025
1 parent 7bb7dbc commit cee3fb4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
18 changes: 9 additions & 9 deletions src/codec/anticipation.Encodable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ package anticipation
import prepositional.*

object Encodable:
given Bytes is Encodable in Bytes as bytes = identity(_)
given Int is Encodable in Text as int = _.toString.tt
given Double is Encodable in Text as double = _.toString.tt
given Byte is Encodable in Text as byte = _.toString.tt
given Short is Encodable in Text as short = _.toString.tt
given Long is Encodable in Text as long = _.toString.tt
given Float is Encodable in Text as float = _.toString.tt
given Text is Encodable in Text as text = identity(_)
given Char is Encodable in Text as char = _.toString.tt
given bytes: Bytes is Encodable in Bytes = identity(_)
given int: Int is Encodable in Text = _.toString.tt
given double: Double is Encodable in Text = _.toString.tt
given byte: Byte is Encodable in Text = _.toString.tt
given short: Short is Encodable in Text = _.toString.tt
given long: Long is Encodable in Text = _.toString.tt
given float: Float is Encodable in Text = _.toString.tt
given text: Text is Encodable in Text = identity(_)
given char: Char is Encodable in Text = _.toString.tt

trait Encodable:
private inline def encodable: this.type = this
Expand Down
6 changes: 3 additions & 3 deletions src/print/anticipation-print.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
package anticipation

package termcapDefinitions:
given Termcap as basic:
given basic: Termcap:
def ansi: Boolean = false
def color: ColorDepth = ColorDepth.NoColor

given Termcap as xterm256:
given xterm256: Termcap:
def ansi: Boolean = true
def color: ColorDepth = ColorDepth.Cube6

given Termcap as xtermTrueColor:
given xtermTrueColor: Termcap:
def ansi: Boolean = true
def color: ColorDepth = ColorDepth.TrueColor
23 changes: 13 additions & 10 deletions src/text/anticipation.Anticipation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,34 @@ object Anticipation:

extension (text: Text) inline def s: String = text

given Text is Addable by Text into Text as addable = _ + _
given Text is Addable by Text into Text = _ + _

private def recur(text: Text, n: Int, acc: Text): Text =
if n == 0 then acc else recur(text, n - 1, acc+text)

given Text is Multiplicable by Int into Text as multiplicable =
(text, n) => recur(text, n.max(0), "".tt)
given multiplicable: Text is Multiplicable by Int into Text = new Multiplicable:
type Self = Text
type Operand = Int
type Result = Text
def multiply(text: Text, n: Int): Text = recur(text, n.max(0), "".tt)

given Ordering[Text] as ordering = Ordering.String.on[Text](identity)
given CommandLineParser.FromString[Text] as fromString = identity(_)
given Ordering[Text] = Ordering.String.on[Text](identity)
given CommandLineParser.FromString[Text] = identity(_)

given (using fromExpr: FromExpr[String]) => FromExpr[Text] as fromExpr:
given fromExpr: (fromExpr: FromExpr[String]) => FromExpr[Text]:
def unapply(expr: Expr[Text])(using Quotes): Option[Text] = fromExpr.unapply(expr)

given ToExpr[Text] as toExpr:
given ToExpr[Text]:
def apply(text: Text)(using Quotes) =
import quotes.reflect.*
val expr = Literal(StringConstant(text)).asExprOf[String]
'{Text($expr)}

given Conversion[String, Text] as stringText = identity(_)
given Conversion[String, Text] = identity(_)

erased given CanEqual[Text, Text] as canEqual = erasedValue
erased given CanEqual[Text, Text] = erasedValue

given Typeable[Text] as typeable:
given Typeable[Text]:
def unapply(value: Any): Option[value.type & Text] = value.asMatchable match
case str: String => Some(str)
case _ => None

0 comments on commit cee3fb4

Please sign in to comment.