-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
222 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,7 @@ bin/ | |
metals.sbt | ||
|
||
# VS-Code | ||
.vscode/ | ||
.vscode/ | ||
|
||
# sbt | ||
.bsp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
modules/core/src/main/scala-3.0.0-M3/util/GetPlatform.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) 2013-2020 Rob Norris and Contributors | ||
// This software is licensed under the MIT License (MIT). | ||
// For more information see LICENSE or https://opensource.org/licenses/MIT | ||
|
||
package doobie.util | ||
|
||
import scala.deriving.Mirror | ||
|
||
trait GetPlatform: | ||
|
||
// Get is available for single-element products. | ||
given x[P <: Product, A]( | ||
using p: Mirror.ProductOf[P], | ||
i: p.MirroredElemTypes =:= (A *: EmptyTuple), | ||
g: Get[A], | ||
): Get[P] = | ||
g.map(a => p.fromProduct(a *: EmptyTuple)) |
17 changes: 17 additions & 0 deletions
17
modules/core/src/main/scala-3.0.0-M3/util/PutPlatform.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) 2013-2020 Rob Norris and Contributors | ||
// This software is licensed under the MIT License (MIT). | ||
// For more information see LICENSE or https://opensource.org/licenses/MIT | ||
|
||
package doobie.util | ||
|
||
import scala.deriving.Mirror | ||
|
||
trait PutPlatform: | ||
|
||
// Put is available for single-element products. | ||
given [P <: Product, A]( | ||
using m: Mirror.ProductOf[P], | ||
i: m.MirroredElemTypes =:= (A *: EmptyTuple), | ||
p: Put[A] | ||
): Put[P] = | ||
p.contramap(p => i(Tuple.fromProductTyped(p)).head) |
64 changes: 64 additions & 0 deletions
64
modules/core/src/main/scala-3.0.0-M3/util/ReadPlatform.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) 2013-2020 Rob Norris and Contributors | ||
// This software is licensed under the MIT License (MIT). | ||
// For more information see LICENSE or https://opensource.org/licenses/MIT | ||
|
||
package doobie.util | ||
|
||
import scala.deriving.Mirror | ||
|
||
trait ReadPlatform: | ||
|
||
// Trivial Read for EmptyTuple | ||
given Read[EmptyTuple] = | ||
new Read[EmptyTuple](Nil, (_, _) => EmptyTuple) | ||
|
||
// Read for head and tail. | ||
given [H, T <: Tuple](using H: => Read[H], T: => Read[T]): Read[H *: T] = | ||
new Read[H *: T]( | ||
H.gets ++ T.gets, | ||
(rs, n) => H.unsafeGet(rs, n) *: T.unsafeGet(rs, n + H.length) | ||
) | ||
|
||
// Generic Read for products. | ||
given [P <: Product, A]( | ||
using m: Mirror.ProductOf[P], | ||
i: A =:= m.MirroredElemTypes, | ||
w: Read[A] | ||
): Read[P] = | ||
w.map(a => m.fromProduct(i(a))) | ||
|
||
given roe: Read[Option[EmptyTuple]] = | ||
new Read[Option[EmptyTuple]](Nil, (_, _) => Some(EmptyTuple)) | ||
|
||
given rou: Read[Option[Unit]] = | ||
new Read[Option[Unit]](Nil, (_, _) => Some(())) | ||
|
||
given cons1[H, T <: Tuple]( | ||
using H: => Read[Option[H]], | ||
T: => Read[Option[T]], | ||
): Read[Option[H *: T]] = | ||
new Read[Option[H *: T]]( | ||
H.gets ++ T.gets, | ||
(rs, n) => | ||
for { | ||
h <- H.unsafeGet(rs, n) | ||
t <- T.unsafeGet(rs, n + H.length) | ||
} yield h *: t | ||
) | ||
|
||
given cons2[H, T <: Tuple]( | ||
using H: => Read[Option[H]], | ||
T: => Read[Option[T]] | ||
): Read[Option[Option[H] *: T]] = | ||
new Read[Option[Option[H] *: T]]( | ||
H.gets ++ T.gets, | ||
(rs, n) => T.unsafeGet(rs, n + H.length).map(H.unsafeGet(rs, n) *: _) | ||
) | ||
|
||
// Generic Read for option of products. | ||
given [P <: Product, A]( | ||
using m: Mirror.ProductOf[P], | ||
i: A =:= m.MirroredElemTypes, | ||
w: Read[Option[A]] | ||
): Read[Option[P]] = | ||
w.map(a => a.map(a => m.fromProduct(i(a)))) |
79 changes: 79 additions & 0 deletions
79
modules/core/src/main/scala-3.0.0-M3/util/WritePlatform.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright (c) 2013-2020 Rob Norris and Contributors | ||
// This software is licensed under the MIT License (MIT). | ||
// For more information see LICENSE or https://opensource.org/licenses/MIT | ||
|
||
package doobie.util | ||
|
||
import scala.deriving.Mirror | ||
|
||
trait WritePlatform: | ||
|
||
// Trivial write for empty tuple. | ||
given Write[EmptyTuple] = | ||
new Write(Nil, _ => Nil, (_, _, _) => (),(_, _, _) => ()) | ||
|
||
// Inductive write for writable head and tail. | ||
given [H, T <: Tuple](using H: => Write[H], T: => Write[T]): Write[H *: T] = | ||
new Write( | ||
H.puts ++ T.puts, | ||
{ case h *: t => H.toList(h) ++ T.toList(t) }, | ||
{ case (ps, n, h *: t) => H.unsafeSet(ps, n, h); T.unsafeSet(ps, n + H.length, t) }, | ||
{ case (rs, n, h *: t) => H.unsafeUpdate(rs, n, h); T.unsafeUpdate(rs, n + H.length, t) } | ||
) | ||
|
||
// Generic write for products. | ||
given [P <: Product, A]( | ||
using m: Mirror.ProductOf[P], | ||
i: m.MirroredElemTypes =:= A, | ||
w: Write[A] | ||
): Write[P] = | ||
w.contramap(p => i(Tuple.fromProductTyped(p))) | ||
|
||
// Trivial write for option of empty tuple. | ||
given woe: Write[Option[EmptyTuple]] = | ||
new Write[Option[EmptyTuple]](Nil, _ => Nil, (_, _, _) => (), (_, _, _) => ()) | ||
|
||
// Trivial write for option of Unit. | ||
given wou: Write[Option[Unit]] = | ||
new Write[Option[Unit]](Nil, _ => Nil, (_, _, _) => (), (_, _, _) => ()) | ||
|
||
// Write[Option[H]], Write[Option[T]] implies Write[Option[H *: T]] | ||
given cons1[H, T <: Tuple]( | ||
using H: => Write[Option[H]], | ||
T: => Write[Option[T]], | ||
// N: H <:!< Option[_], | ||
): Write[Option[H *: T]] = | ||
|
||
def split[A](i: Option[H *: T])(f: (Option[H], Option[T]) => A): A = | ||
i.fold(f(None, None)) { case h *: t => f(Some(h), Some(t)) } | ||
|
||
new Write( | ||
H.puts ++ T.puts, | ||
split(_) { (h, t) => H.toList(h) ++ T.toList(t) }, | ||
(ps, n, i) => split(i) { (h, t) => H.unsafeSet(ps, n, h); T.unsafeSet(ps, n + H.length, t) }, | ||
(rs, n, i) => split(i) { (h, t) => H.unsafeUpdate(rs, n, h); T.unsafeUpdate(rs, n + H.length, t) } | ||
) | ||
|
||
// Write[Option[H]], Write[Option[T]] implies Write[Option[Option[H] *: T]] | ||
given cons2[H, T <: Tuple]( | ||
using H: => Write[Option[H]], | ||
T: => Write[Option[T]] | ||
): Write[Option[Option[H] *: T]] = | ||
|
||
def split[A](i: Option[Option[H] *: T])(f: (Option[H], Option[T]) => A): A = | ||
i.fold(f(None, None)) { case oh *: t => f(oh, Some(t)) } | ||
|
||
new Write( | ||
H.puts ++ T.puts, | ||
split(_) { (h, t) => H.toList(h) ++ T.toList(t) }, | ||
(ps, n, i) => split(i) { (h, t) => H.unsafeSet(ps, n, h); T.unsafeSet(ps, n + H.length, t) }, | ||
(rs, n, i) => split(i) { (h, t) => H.unsafeUpdate(rs, n, h); T.unsafeUpdate(rs, n + H.length, t) } | ||
) | ||
|
||
// Generic write for options of products. | ||
given [P <: Product, A]( | ||
using m: Mirror.ProductOf[P], | ||
i: m.MirroredElemTypes =:= A, | ||
w: Write[Option[A]] | ||
): Write[Option[P]] = | ||
w.contramap(op => op.map(p => i(Tuple.fromProductTyped(p)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
modules/postgres/src/main/scala-3.0.0-M3/doobie/postgres/TextPlatform.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2013-2020 Rob Norris and Contributors | ||
// This software is licensed under the MIT License (MIT). | ||
// For more information see LICENSE or https://opensource.org/licenses/MIT | ||
|
||
package doobie.postgres | ||
|
||
import scala.deriving.Mirror | ||
|
||
trait TextPlatform { this: Text.type => | ||
|
||
// EmptyTuple isn't a valid Text but a single-element Tuple is | ||
given [A](using csv: Text[A]): Text[A *: EmptyTuple] = | ||
csv.contramap(_.head) | ||
|
||
// Tuples of more that one element | ||
given [H, T <: Tuple](using h: Text[H], t: Text[T]): Text[H *: T] = | ||
(h product t).contramap(l => (l.head, l.tail)) | ||
|
||
// Put is available for single-element products. | ||
given [P <: Product, A]( | ||
using m: Mirror.ProductOf[P], | ||
i: m.MirroredElemTypes =:= A, | ||
t: Text[A] | ||
): Text[P] = | ||
t.contramap(p => i(Tuple.fromProductTyped(p))) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=1.3.9 | ||
sbt.version=1.4.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.8.0") | ||
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.1") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") | ||
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.5") | ||
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") | ||
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.1") | ||
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7") | ||
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.0") | ||
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") | ||
addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2") | ||
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16") | ||
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.14") | ||
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.6") | ||
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.1") |