Skip to content

Commit

Permalink
use new Scala 3 syntax. prepare latest Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Aug 26, 2024
1 parent d83b1a8 commit 037064f
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bench/src/main/scala/monocle/bench/BenchModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object BenchModel {
case class Point3(x: Int, y: Int, z: Int)
val p = Point3(2, 10, 24)

val map = SortedMap(1.to(200).map(_ -> 5): _*)
val map = SortedMap(1.to(200).map(_ -> 5) *)

case class IntWrapper0(i: Int)
case class IntWrapper1(i: Int)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/scala/monocle/docs/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import scala.collection.Seq

object Main {
def sourceDirectoryPath(rest: String*): Path =
FileSystems.getDefault.getPath(sourceDirectory.getAbsolutePath, rest: _*)
FileSystems.getDefault.getPath(sourceDirectory.getAbsolutePath, rest *)

def minorVersion(version: String): String = {
val Array(major, minor, _) = version.split('.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ object AtTests extends Laws {
evAt: At[S, I, A],
arbAA: Arbitrary[A => A]
): RuleSet =
new SimpleRuleSet("At", LensTests[S, A, I](at(_)).props: _*)
new SimpleRuleSet("At", LensTests[S, A, I](at(_)).props *)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ object Cons1Tests extends Laws {
): RuleSet =
new SimpleRuleSet(
"Cons1",
IsoTests(cons1[S, H, T]).props ++
(IsoTests(cons1[S, H, T]).props ++
LensTests(head[S, H, T]).props ++
LensTests(tail[S, H, T]).props: _*
LensTests(tail[S, H, T]).props) *
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ object ConsTests extends Laws {
): RuleSet =
new SimpleRuleSet(
"Cons",
PrismTests(cons[S, A]).props ++
(PrismTests(cons[S, A]).props ++
OptionalTests(headOption[S, A]).props ++
OptionalTests(tailOption[S, A]).props: _*
OptionalTests(tailOption[S, A]).props) *
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ import cats.Eq

object EachTests extends Laws {
def apply[S: Eq: Arbitrary, A: Eq: Arbitrary](implicit evEach: Each[S, A], arbAA: Arbitrary[A => A]): RuleSet =
new SimpleRuleSet("Each", TraversalTests(each[S, A]).props: _*)
new SimpleRuleSet("Each", TraversalTests(each[S, A]).props *)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ object FilterIndexTests extends Laws {
arbAA: Arbitrary[A => A],
arbIB: Arbitrary[I => Boolean]
): RuleSet =
new SimpleRuleSet("FilterIndex", TraversalTests(filterIndex(_: I => Boolean)(evFilterIndex)).props: _*)
new SimpleRuleSet("FilterIndex", TraversalTests(filterIndex(_: I => Boolean)(evFilterIndex)).props *)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ object IndexTests extends Laws {
evIndex: Index[S, I, A],
arbAA: Arbitrary[A => A]
): RuleSet =
new SimpleRuleSet("Index", OptionalTests(index(_: I)(evIndex)).props: _*)
new SimpleRuleSet("Index", OptionalTests(index(_: I)(evIndex)).props *)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ object PossibleTests extends Laws {
evPossible: Possible[S, A],
arbAA: Arbitrary[A => A]
): RuleSet =
new SimpleRuleSet("Possible", OptionalTests(possible[S, A]).props: _*)
new SimpleRuleSet("Possible", OptionalTests(possible[S, A]).props *)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ object Snoc1Tests extends Laws {
): RuleSet =
new SimpleRuleSet(
"Snoc1",
IsoTests(snoc1[S, I, L]).props ++
(IsoTests(snoc1[S, I, L]).props ++
LensTests(init[S, I, L]).props ++
LensTests(last[S, I, L]).props: _*
LensTests(last[S, I, L]).props) *
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ object SnocTests extends Laws {
): RuleSet =
new SimpleRuleSet(
"Snoc",
PrismTests(snoc[S, A]).props ++
(PrismTests(snoc[S, A]).props ++
OptionalTests(lastOption[S, A]).props ++
OptionalTests(initOption[S, A]).props: _*
OptionalTests(initOption[S, A]).props) *
)
}
2 changes: 1 addition & 1 deletion test/shared/src/test/scala/monocle/TestInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ trait TestInstances extends PlatformSpecificTestInstances with cats.instances.Al
Arbitrary(Arbitrary.arbitrary[List[A]].map(_.toVector))

implicit def listMapArbitrary[K: Arbitrary, V: Arbitrary]: Arbitrary[ListMap[K, V]] =
Arbitrary(Arbitrary.arbitrary[List[(K, V)]].map(l => ListMap(l: _*)))
Arbitrary(Arbitrary.arbitrary[List[(K, V)]].map(l => ListMap(l *)))

implicit def mapArbitrary[K: Arbitrary, V: Arbitrary]: Arbitrary[Map[K, V]] =
Arbitrary(Arbitrary.arbitrary[List[(K, V)]].map(_.toMap))
Expand Down
6 changes: 3 additions & 3 deletions test/shared/src/test/scala/monocle/function/Data.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object MSorteMap {

implicit def mmapEq[K, V]: Eq[MSorteMap[K, V]] = Eq.fromUniversalEquals
implicit def mmapArb[K: Arbitrary, V: Arbitrary](implicit ok: Order[K]): Arbitrary[MSorteMap[K, V]] =
Arbitrary(Arbitrary.arbitrary[List[(K, V)]].map(kvs => MSorteMap(SortedMap(kvs: _*)(ok.toOrdering))))
Arbitrary(Arbitrary.arbitrary[List[(K, V)]].map(kvs => MSorteMap(SortedMap(kvs *)(ok.toOrdering))))
}

case class MMap[K, V](map: Map[K, V])
Expand All @@ -27,7 +27,7 @@ object MMap {

implicit def mmapEq[K, V]: Eq[MMap[K, V]] = Eq.fromUniversalEquals
implicit def mmapArb[K: Arbitrary, V: Arbitrary]: Arbitrary[MMap[K, V]] =
Arbitrary(Arbitrary.arbitrary[List[(K, V)]].map(kvs => MMap(Map(kvs: _*))))
Arbitrary(Arbitrary.arbitrary[List[(K, V)]].map(kvs => MMap(Map(kvs *))))
}

case class CNel(head: Char, tail: List[Char])
Expand Down Expand Up @@ -68,7 +68,7 @@ case class Raw(b: Boolean, c: Char, i: Int, l: Long, f: Float, d: Double)

object Raw extends TestInstances {
val toTuple: Iso[Raw, (Boolean, Char, Int, Long, Float, Double)] =
Iso((r: Raw) => (r.b, r.c, r.i, r.l, r.f, r.d))((Raw.apply _) tupled)
Iso((r: Raw) => (r.b, r.c, r.i, r.l, r.f, r.d))(Raw.apply.tupled)

implicit val rawEq: Eq[Raw] = Eq.fromUniversalEquals
implicit val rawArb: Arbitrary[Raw] = Arbitrary(
Expand Down
6 changes: 3 additions & 3 deletions test/shared/src/test/scala/monocle/function/PlatedSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class PlatedSpec extends MonocleSuite {
case _ => None
}

private val negateAll = Plated.transform(negate) _
private val negateAll = Plated.transform(negate)

private val addAll = Plated.rewrite(add) _
private val addAll = Plated.rewrite(add)

private val universe = Plated.universe[Expr] _
private val universe = Plated.universe[Expr]

test("apply rule everywhere until that rule cannot be applied anywhere") {
val e = Add(Add(Val(1), Val(2)), Val(3))
Expand Down
2 changes: 1 addition & 1 deletion unsafe/src/main/scala/monocle/unsafe/MapTraversal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object MapTraversal {
.traverse { case (k, v) =>
(if (predicate(k)) f(v) else v.pure[F]).tupleLeft(k)
}
.map(kvs => Map(kvs: _*))
.map(kvs => Map(kvs *))
}
}
}

0 comments on commit 037064f

Please sign in to comment.