Skip to content

Commit 2e4927d

Browse files
Fix formatting
1 parent e252cee commit 2e4927d

File tree

6 files changed

+127
-57
lines changed

6 files changed

+127
-57
lines changed

cats-derivation/src/main/scala/hearth/kindlings/catsderivation/internal/compiletime/rules/EmptyBuiltInRule.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait EmptyBuiltInRuleImpl {
1010

1111
object EmptyBuiltInRule extends EmptyDerivationRule("built-in Empty for primitives") {
1212

13-
def apply[A: EmptyCtx]: MIO[Rule.Applicability[Expr[A]]] = {
13+
def apply[A: EmptyCtx]: MIO[Rule.Applicability[Expr[A]]] =
1414
Log.info(s"Checking built-in Empty for ${Type[A].prettyPrint}") >> MIO {
1515
if (Type[A] <:< EmptyTypes.Boolean)
1616
Rule.matched(Expr(false).asInstanceOf[Expr[A]])
@@ -33,6 +33,5 @@ trait EmptyBuiltInRuleImpl {
3333
else
3434
Rule.yielded(s"${Type[A].prettyPrint} is not a built-in Empty type")
3535
}
36-
}
3736
}
3837
}

cats-derivation/src/main/scala/hearth/kindlings/catsderivation/internal/compiletime/rules/EmptyEnumRule.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ trait EmptyEnumRuleImpl {
3535
case List(singleEmpty) =>
3636
MIO.pure(Rule.matched(singleEmpty))
3737
case Nil =>
38-
MIO.pure(Rule.yielded(
39-
s"${Type[A].prettyPrint}: no variant has an Empty instance"
40-
))
38+
MIO.pure(
39+
Rule.yielded(
40+
s"${Type[A].prettyPrint}: no variant has an Empty instance"
41+
)
42+
)
4143
case _ =>
4244
MIO.fail(EmptyDerivationError.MultipleEmptyVariants(Type[A].prettyPrint))
4345
}

cats-derivation/src/main/scala/hearth/kindlings/catsderivation/internal/compiletime/rules/MonoidBuiltInRule.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait MonoidBuiltInRuleImpl {
1111
@scala.annotation.nowarn("msg=is never used")
1212
object MonoidBuiltInRule extends MonoidDerivationRule("built-in Monoid for primitives") {
1313

14-
def apply[A: MonoidCtx]: MIO[Rule.Applicability[MonoidDerivationResult[A]]] = {
14+
def apply[A: MonoidCtx]: MIO[Rule.Applicability[MonoidDerivationResult[A]]] =
1515
Log.info(s"Checking built-in Monoid for ${Type[A].prettyPrint}") >> MIO {
1616
if (Type[A] <:< SemigroupTypes.Byte)
1717
Rule.matched(mkNumericMonoid[A](Expr(0.toByte).asInstanceOf[Expr[A]]))
@@ -30,7 +30,6 @@ trait MonoidBuiltInRuleImpl {
3030
else
3131
Rule.yielded(s"${Type[A].prettyPrint} is not a built-in Monoid type")
3232
}
33-
}
3433

3534
private def mkNumericMonoid[A: MonoidCtx](emptyVal: Expr[A]): MonoidDerivationResult[A] = {
3635
val combine: (Expr[A], Expr[A]) => MIO[Expr[A]] = (x, y) => {

cats-derivation/src/main/scala/hearth/kindlings/catsderivation/internal/compiletime/rules/MonoidUseCachedRule.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ trait MonoidUseCachedRuleImpl {
1616
moidctx.cache.get0Ary[cats.kernel.Monoid[A]]("cached-monoid-instance").flatMap {
1717
case Some(instance) =>
1818
val empty = Expr.quote(Expr.splice(instance).empty)
19-
val combine: (Expr[A], Expr[A]) => MIO[Expr[A]] = (x, y) =>
20-
MIO.pure(Expr.quote(Expr.splice(instance).combine(Expr.splice(x), Expr.splice(y))))
19+
val combine: (Expr[A], Expr[A]) => MIO[Expr[A]] =
20+
(x, y) => MIO.pure(Expr.quote(Expr.splice(instance).combine(Expr.splice(x), Expr.splice(y))))
2121
MIO.pure(Rule.matched(MonoidDerivationResult(empty, combine)))
2222
case None =>
2323
MIO.pure(Rule.yielded(s"No cached Monoid for ${Type[A].prettyPrint}"))

cats-derivation/src/main/scala/hearth/kindlings/catsderivation/internal/compiletime/rules/OrderBuiltInRule.scala

Lines changed: 69 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,83 @@ trait OrderBuiltInRuleImpl {
2323
implicit val StringType: Type[String] = OrderTypes.String
2424
Log.info(s"Checking built-in Order for ${Type[A].prettyPrint}") >> MIO {
2525
if (Type[A] <:< OrderTypes.Boolean)
26-
Rule.matched(Expr.quote(java.lang.Boolean.compare(
27-
Expr.splice(octx.x.upcast[Boolean]), Expr.splice(octx.y.upcast[Boolean])
28-
)))
26+
Rule.matched(
27+
Expr.quote(
28+
java.lang.Boolean.compare(
29+
Expr.splice(octx.x.upcast[Boolean]),
30+
Expr.splice(octx.y.upcast[Boolean])
31+
)
32+
)
33+
)
2934
else if (Type[A] <:< OrderTypes.Byte)
30-
Rule.matched(Expr.quote(java.lang.Byte.compare(
31-
Expr.splice(octx.x.upcast[Byte]), Expr.splice(octx.y.upcast[Byte])
32-
)))
35+
Rule.matched(
36+
Expr.quote(
37+
java.lang.Byte.compare(
38+
Expr.splice(octx.x.upcast[Byte]),
39+
Expr.splice(octx.y.upcast[Byte])
40+
)
41+
)
42+
)
3343
else if (Type[A] <:< OrderTypes.Short)
34-
Rule.matched(Expr.quote(java.lang.Short.compare(
35-
Expr.splice(octx.x.upcast[Short]), Expr.splice(octx.y.upcast[Short])
36-
)))
44+
Rule.matched(
45+
Expr.quote(
46+
java.lang.Short.compare(
47+
Expr.splice(octx.x.upcast[Short]),
48+
Expr.splice(octx.y.upcast[Short])
49+
)
50+
)
51+
)
3752
else if (Type[A] <:< OrderTypes.Int)
38-
Rule.matched(Expr.quote(java.lang.Integer.compare(
39-
Expr.splice(octx.x.upcast[Int]), Expr.splice(octx.y.upcast[Int])
40-
)))
53+
Rule.matched(
54+
Expr.quote(
55+
java.lang.Integer.compare(
56+
Expr.splice(octx.x.upcast[Int]),
57+
Expr.splice(octx.y.upcast[Int])
58+
)
59+
)
60+
)
4161
else if (Type[A] <:< OrderTypes.Long)
42-
Rule.matched(Expr.quote(java.lang.Long.compare(
43-
Expr.splice(octx.x.upcast[Long]), Expr.splice(octx.y.upcast[Long])
44-
)))
62+
Rule.matched(
63+
Expr.quote(
64+
java.lang.Long.compare(
65+
Expr.splice(octx.x.upcast[Long]),
66+
Expr.splice(octx.y.upcast[Long])
67+
)
68+
)
69+
)
4570
else if (Type[A] <:< OrderTypes.Float)
46-
Rule.matched(Expr.quote(java.lang.Float.compare(
47-
Expr.splice(octx.x.upcast[Float]), Expr.splice(octx.y.upcast[Float])
48-
)))
71+
Rule.matched(
72+
Expr.quote(
73+
java.lang.Float.compare(
74+
Expr.splice(octx.x.upcast[Float]),
75+
Expr.splice(octx.y.upcast[Float])
76+
)
77+
)
78+
)
4979
else if (Type[A] <:< OrderTypes.Double)
50-
Rule.matched(Expr.quote(java.lang.Double.compare(
51-
Expr.splice(octx.x.upcast[Double]), Expr.splice(octx.y.upcast[Double])
52-
)))
80+
Rule.matched(
81+
Expr.quote(
82+
java.lang.Double.compare(
83+
Expr.splice(octx.x.upcast[Double]),
84+
Expr.splice(octx.y.upcast[Double])
85+
)
86+
)
87+
)
5388
else if (Type[A] <:< OrderTypes.Char)
54-
Rule.matched(Expr.quote(java.lang.Character.compare(
55-
Expr.splice(octx.x.upcast[Char]), Expr.splice(octx.y.upcast[Char])
56-
)))
89+
Rule.matched(
90+
Expr.quote(
91+
java.lang.Character.compare(
92+
Expr.splice(octx.x.upcast[Char]),
93+
Expr.splice(octx.y.upcast[Char])
94+
)
95+
)
96+
)
5797
else if (Type[A] <:< OrderTypes.String)
58-
Rule.matched(Expr.quote(
59-
Expr.splice(octx.x.upcast[String]).compareTo(Expr.splice(octx.y.upcast[String]))
60-
))
98+
Rule.matched(
99+
Expr.quote(
100+
Expr.splice(octx.x.upcast[String]).compareTo(Expr.splice(octx.y.upcast[String]))
101+
)
102+
)
61103
else
62104
Rule.yielded(s"${Type[A].prettyPrint} is not a built-in type")
63105
}

cats-derivation/src/main/scala/hearth/kindlings/catsderivation/internal/compiletime/rules/SemigroupBuiltInRule.scala

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,61 @@ trait SemigroupBuiltInRuleImpl {
2121
implicit val StringType: Type[String] = SemigroupTypes.String
2222
Log.info(s"Checking built-in Semigroup for ${Type[A].prettyPrint}") >> MIO {
2323
if (Type[A] <:< SemigroupTypes.Byte)
24-
Rule.matched(Expr.quote(
25-
(Expr.splice(sgctx.x.upcast[Byte]) + Expr.splice(sgctx.y.upcast[Byte])).toByte
26-
).asInstanceOf[Expr[A]])
24+
Rule.matched(
25+
Expr
26+
.quote(
27+
(Expr.splice(sgctx.x.upcast[Byte]) + Expr.splice(sgctx.y.upcast[Byte])).toByte
28+
)
29+
.asInstanceOf[Expr[A]]
30+
)
2731
else if (Type[A] <:< SemigroupTypes.Short)
28-
Rule.matched(Expr.quote(
29-
(Expr.splice(sgctx.x.upcast[Short]) + Expr.splice(sgctx.y.upcast[Short])).toShort
30-
).asInstanceOf[Expr[A]])
32+
Rule.matched(
33+
Expr
34+
.quote(
35+
(Expr.splice(sgctx.x.upcast[Short]) + Expr.splice(sgctx.y.upcast[Short])).toShort
36+
)
37+
.asInstanceOf[Expr[A]]
38+
)
3139
else if (Type[A] <:< SemigroupTypes.Int)
32-
Rule.matched(Expr.quote(
33-
Expr.splice(sgctx.x.upcast[Int]) + Expr.splice(sgctx.y.upcast[Int])
34-
).asInstanceOf[Expr[A]])
40+
Rule.matched(
41+
Expr
42+
.quote(
43+
Expr.splice(sgctx.x.upcast[Int]) + Expr.splice(sgctx.y.upcast[Int])
44+
)
45+
.asInstanceOf[Expr[A]]
46+
)
3547
else if (Type[A] <:< SemigroupTypes.Long)
36-
Rule.matched(Expr.quote(
37-
Expr.splice(sgctx.x.upcast[Long]) + Expr.splice(sgctx.y.upcast[Long])
38-
).asInstanceOf[Expr[A]])
48+
Rule.matched(
49+
Expr
50+
.quote(
51+
Expr.splice(sgctx.x.upcast[Long]) + Expr.splice(sgctx.y.upcast[Long])
52+
)
53+
.asInstanceOf[Expr[A]]
54+
)
3955
else if (Type[A] <:< SemigroupTypes.Float)
40-
Rule.matched(Expr.quote(
41-
Expr.splice(sgctx.x.upcast[Float]) + Expr.splice(sgctx.y.upcast[Float])
42-
).asInstanceOf[Expr[A]])
56+
Rule.matched(
57+
Expr
58+
.quote(
59+
Expr.splice(sgctx.x.upcast[Float]) + Expr.splice(sgctx.y.upcast[Float])
60+
)
61+
.asInstanceOf[Expr[A]]
62+
)
4363
else if (Type[A] <:< SemigroupTypes.Double)
44-
Rule.matched(Expr.quote(
45-
Expr.splice(sgctx.x.upcast[Double]) + Expr.splice(sgctx.y.upcast[Double])
46-
).asInstanceOf[Expr[A]])
64+
Rule.matched(
65+
Expr
66+
.quote(
67+
Expr.splice(sgctx.x.upcast[Double]) + Expr.splice(sgctx.y.upcast[Double])
68+
)
69+
.asInstanceOf[Expr[A]]
70+
)
4771
else if (Type[A] <:< SemigroupTypes.String)
48-
Rule.matched(Expr.quote(
49-
Expr.splice(sgctx.x.upcast[String]) + Expr.splice(sgctx.y.upcast[String])
50-
).asInstanceOf[Expr[A]])
72+
Rule.matched(
73+
Expr
74+
.quote(
75+
Expr.splice(sgctx.x.upcast[String]) + Expr.splice(sgctx.y.upcast[String])
76+
)
77+
.asInstanceOf[Expr[A]]
78+
)
5179
else
5280
Rule.yielded(s"${Type[A].prettyPrint} is not a built-in Semigroup type")
5381
}

0 commit comments

Comments
 (0)