Skip to content

Commit

Permalink
Reverted Scala 3.6.2 given syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
horothesun committed Dec 11, 2024
1 parent 69d7f0e commit 099e0cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/Day01.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object Day01:

opaque type Calibration = Int
object Calibration:
given Monoid[Calibration]:
given Monoid[Calibration] with
val empty: Calibration = 0
def combine(c1: Calibration, c2: Calibration): Calibration = c1 + c2

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/Day02.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object Day02:
case Possible, Impossible

object Validity:
given Monoid[Validity]:
given Monoid[Validity] with
def empty: Validity = Possible
def combine(x: Validity, y: Validity): Validity = if (x == Impossible || y == Impossible) Impossible else Possible

Expand Down
18 changes: 9 additions & 9 deletions src/main/scala/Day05.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,47 @@ object Day05:
trait Identified:
def id: Long

trait Constructed[A]:
trait Constructed[A] with
def cons(id: Long): A

case class Seed(id: Long) extends Identified
object Seed:
given Constructed[Seed]:
given Constructed[Seed] with
def cons(id: Long): Seed = Seed(id)

case class Soil(id: Long) extends Identified
object Soil:
given Constructed[Soil]:
given Constructed[Soil] with
def cons(id: Long): Soil = Soil(id)

case class Fertilizer(id: Long) extends Identified
object Fertilizer:
given Constructed[Fertilizer]:
given Constructed[Fertilizer] with
def cons(id: Long): Fertilizer = Fertilizer(id)

case class Water(id: Long) extends Identified
object Water:
given Constructed[Water]:
given Constructed[Water] with
def cons(id: Long): Water = Water(id)

case class Light(id: Long) extends Identified
object Light:
given Constructed[Light]:
given Constructed[Light] with
def cons(id: Long): Light = Light(id)

case class Temperature(id: Long) extends Identified
object Temperature:
given Constructed[Temperature]:
given Constructed[Temperature] with
def cons(id: Long): Temperature = Temperature(id)

case class Humidity(id: Long) extends Identified
object Humidity:
given Constructed[Humidity]:
given Constructed[Humidity] with
def cons(id: Long): Humidity = Humidity(id)

case class Location(id: Long) extends Identified
object Location:
given Constructed[Location]:
given Constructed[Location] with
def cons(id: Long): Location = Location(id)

given Ordering[Location] = Ordering.fromLessThan((l, r) => l.id < r.id)
Expand Down

0 comments on commit 099e0cc

Please sign in to comment.