From 099e0cc510020deffb493678727c9176e58e7c27 Mon Sep 17 00:00:00 2001 From: horothesun Date: Wed, 11 Dec 2024 00:56:36 +0000 Subject: [PATCH] Reverted Scala 3.6.2 given syntax --- src/main/scala/Day01.scala | 2 +- src/main/scala/Day02.scala | 2 +- src/main/scala/Day05.scala | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/scala/Day01.scala b/src/main/scala/Day01.scala index ffc3eb3..968c1a3 100644 --- a/src/main/scala/Day01.scala +++ b/src/main/scala/Day01.scala @@ -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 diff --git a/src/main/scala/Day02.scala b/src/main/scala/Day02.scala index 32d2421..0754516 100644 --- a/src/main/scala/Day02.scala +++ b/src/main/scala/Day02.scala @@ -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 diff --git a/src/main/scala/Day05.scala b/src/main/scala/Day05.scala index 6cbb3dd..1694ff7 100644 --- a/src/main/scala/Day05.scala +++ b/src/main/scala/Day05.scala @@ -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)