Skip to content

Commit d6937f0

Browse files
committed
Run scalafmt
1 parent 6e0b01f commit d6937f0

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

core/shared/src/main/scala/porcupine/codec.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ trait Codec[A] extends Encoder[A], Decoder[A]:
121121

122122
object Codec:
123123
extension [H](head: Codec[H])
124-
def *:[T <: Tuple](tail: Codec[T]): Codec[H *: T] = (head, tail).imapN(_ *: _) { case h *: t => (h, t) }
124+
def *:[T <: Tuple](tail: Codec[T]): Codec[H *: T] = (head, tail).imapN(_ *: _) {
125+
case h *: t => (h, t)
126+
}
125127

126128
private final class Simple[T](
127-
name: String,
128-
apply: T => LiteValue,
129-
unapply: PartialFunction[LiteValue, T]
129+
name: String,
130+
apply: T => LiteValue,
131+
unapply: PartialFunction[LiteValue, T],
130132
) extends Codec[T] {
131133
override def parameters: Int = 1
132134
override def encode(a: T): List[LiteValue] = apply(a) :: Nil

core/shared/src/main/scala/porcupine/sql.scala

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ object Query:
3535
Query(fab.sql, fab.encoder.contramap(f), fab.decoder.map(g))
3636

3737
final class Fragment[A](
38-
val parts: List[Either[String, Int]],
39-
val encoder: Encoder[A]
38+
val parts: List[Either[String, Int]],
39+
val encoder: Encoder[A],
4040
):
4141
def sql: String = parts.foldMap {
4242
case Left(s) => s
@@ -57,7 +57,9 @@ final class Fragment[A](
5757
val ps = head.map {
5858
_.leftMap(_.stripMargin(marginChar))
5959
}.toList ++ tail.map {
60-
_.leftMap(str => str.takeWhile(_ != '\n') + str.dropWhile(_ != '\n').stripMargin(marginChar))
60+
_.leftMap(str =>
61+
str.takeWhile(_ != '\n') + str.dropWhile(_ != '\n').stripMargin(marginChar),
62+
)
6163
}
6264
Fragment(ps, encoder)
6365

@@ -90,14 +92,15 @@ private def sqlImpl(
9092
val args = Varargs.unapply(argsExpr).toList.flatMap(_.toList)
9193

9294
// TODO appending to `List` is slow
93-
val fragment = parts.zipAll(args, '{ "" }, '{ "" }).foldLeft('{ List.empty[Either[String, Int]] }) {
94-
case ('{ $acc: List[Either[String, Int]] }, ('{ $p: String }, '{ $s: String })) =>
95-
'{ $acc :+ Left($p) :+ Left($s) }
96-
case ('{ $acc: List[Either[String, Int]] }, ('{ $p: String }, '{ $e: Encoder[t] })) =>
97-
'{ $acc :+ Left($p) :+ Right($e.parameters) }
98-
case ('{ $acc: List[Either[String, Int]] }, ('{ $p: String }, '{ $f: Fragment[t] })) =>
99-
'{ $acc :+ Left($p) :++ $f.parts }
100-
}
95+
val fragment =
96+
parts.zipAll(args, '{ "" }, '{ "" }).foldLeft('{ List.empty[Either[String, Int]] }) {
97+
case ('{ $acc: List[Either[String, Int]] }, ('{ $p: String }, '{ $s: String })) =>
98+
'{ $acc :+ Left($p) :+ Left($s) }
99+
case ('{ $acc: List[Either[String, Int]] }, ('{ $p: String }, '{ $e: Encoder[t] })) =>
100+
'{ $acc :+ Left($p) :+ Right($e.parameters) }
101+
case ('{ $acc: List[Either[String, Int]] }, ('{ $p: String }, '{ $f: Fragment[t] })) =>
102+
'{ $acc :+ Left($p) :++ $f.parts }
103+
}
101104

102105
val encoder = args.collect {
103106
case '{ $e: Encoder[t] } => e

core/shared/src/test/scala/porcupine/PorcupineTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object PorcupineTest extends IOApp.Simple:
2929
val q = `null` *: integer *: real *: text *: blob *: nil
3030
db.execute(sql"create table porcupine (n, i, r, t, b);".command) *>
3131
db.execute(
32-
sql"insert into porcupine values(${ q });".command,
32+
sql"insert into porcupine values(${q});".command,
3333
(None, 42L, 3.14, "quill-pig", ByteVector(0, 1, 2, 3)),
3434
) *>
3535
db.unique(

0 commit comments

Comments
 (0)