Skip to content

Commit

Permalink
go
Browse files Browse the repository at this point in the history
  • Loading branch information
jatcwang committed Oct 29, 2024
1 parent 8591ab4 commit 641c1eb
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 48 deletions.
6 changes: 0 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ lazy val doobie = project.in(file("."))
bench,
core,
docs,
fixme,
example,
free,
h2,
Expand Down Expand Up @@ -294,11 +293,6 @@ lazy val log4cats = project
libraryDependencies += "org.typelevel" %% "log4cats-core" % log4catsVersion
)

lazy val fixme = project
.in(file("modules/fixme"))
.settings(doobieSettings)
.dependsOn(core)

lazy val example = project
.in(file("modules/example"))
.enablePlugins(NoPublishPlugin)
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/main/scala-3/doobie/util/MkReadPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import doobie.util.shapeless.OrElse
trait MkReadPlatform:

// Derivation for product types (i.e. case class)
given derived[P <: Product, A](
using
implicit def derived[P <: Product, A](
implicit
m: Mirror.ProductOf[P],
i: A =:= m.MirroredElemTypes,
r: Read[A] `OrElse` Derived[MkRead[A]]
Expand All @@ -21,8 +21,8 @@ trait MkReadPlatform:
}

// Derivation base case for tuple (1-element)
given productBase[H](
using H: Read[H] `OrElse` Derived[MkRead[H]]
implicit def productBase[H](
implicit H: Read[H] `OrElse` Derived[MkRead[H]]
): Derived[MkRead[H *: EmptyTuple]] = {
val headInstance = H.fold(identity, _.instance)
new Derived(
Expand All @@ -35,8 +35,8 @@ trait MkReadPlatform:
}

// Derivation inductive case for tuples
given product[H, T <: Tuple](
using
implicit def product[H, T <: Tuple](
implicit
H: Read[H] `OrElse` Derived[MkRead[H]],
T: Read[T] `OrElse` Derived[MkRead[T]]
): Derived[MkRead[H *: T]] = {
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/main/scala-3/doobie/util/MkWritePlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import doobie.util.shapeless.OrElse
trait MkWritePlatform:

// Derivation for product types (i.e. case class)
given derived[P <: Product, A](
using
implicit def derived[P <: Product, A](
implicit
m: Mirror.ProductOf[P],
i: m.MirroredElemTypes =:= A,
w: Derived[MkWrite[A]]
Expand All @@ -22,8 +22,8 @@ trait MkWritePlatform:
)

// Derivation base case for tuple (1-element)
given productBase[H](
using H: Write[H] `OrElse` Derived[MkWrite[H]]
implicit def productBase[H](
implicit H: Write[H] `OrElse` Derived[MkWrite[H]]
): Derived[MkWrite[H *: EmptyTuple]] = {
val headInstance = H.fold(identity, _.instance)
new Derived(
Expand All @@ -35,8 +35,8 @@ trait MkWritePlatform:
}

// Derivation inductive case for tuples
given product[H, T <: Tuple](
using
implicit def product[H, T <: Tuple](
implicit
H: Write[H] `OrElse` Derived[MkWrite[H]],
T: Write[H] `OrElse` Derived[MkWrite[H]]
): Derived[MkWrite[H *: T]] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import doobie.testutils.TestClasses.{CCIntString, PlainObj, CCAnyVal}
trait GetSuitePlatform { self: munit.FunSuite =>

test("Get can be auto derived for unary products (AnyVal)") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Get[CCAnyVal].void
}
Expand All @@ -19,7 +19,7 @@ trait GetSuitePlatform { self: munit.FunSuite =>
}

test("Get should not be derived for non-unary products") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

assertContains(compileErrors("Get[CCIntString]"), "implicit value")
assertContains(compileErrors("Get[(Int, Int)]"), "implicit value")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import doobie.testutils.TestClasses.{CCIntString, PlainObj, CCAnyVal}

trait PutSuitePlatform { self: munit.FunSuite =>
test("Put can be auto derived for unary products (AnyVal)") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Put[CCAnyVal].void
}
Expand All @@ -18,7 +18,7 @@ trait PutSuitePlatform { self: munit.FunSuite =>
}

test("Put should not be derived for non-unary products") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

assertContains(compileErrors("Put[CCIntString]"), "implicit value")
assertContains(compileErrors("Put[(Int, Int)]"), "implicit value")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait PutSuitePlatform { self: munit.FunSuite =>
test("Put should be derived for unary products (AnyVal)".ignore) {}

test("Put should not be derived for non-unary products") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*
import doobie.testutils.TestClasses.{CCIntString, PlainObj}

assertContains(compileErrors("Put[CCIntString]"), "No given instance")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package doobie.util
import doobie.util.log.{Parameters, Success, ProcessingFailure}

trait QueryLogSuitePlatform { self: QueryLogSuite =>
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

test("[Query] n-arg success") {
val Sql = "select 1 where ? = ?"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ trait ReadSuitePlatform { self: munit.FunSuite =>
case class CaseClassWithFieldWithoutGetInstance(a: String, b: NoGetInstanceForThis)

test("Read should exist for some fancy types") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Read[Woozle].void
Read[(Woozle, String)].void
Read[(Int, Woozle *: Woozle *: String *: EmptyTuple)].void
}

test("Read should exist for option of some fancy types") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Read[Option[Woozle]].void
Read[Option[(Woozle, String)]].void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ trait WriteSuitePlatform { self: munit.FunSuite =>
case class CaseClassWithFieldWithoutPutInstance(a: String, b: NoPutInstanceForThis)

test("Write should exist for some fancy types") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Write[Woozle].void
Write[(Woozle, String)].void
Write[(Int, Woozle *: Woozle *: String *: EmptyTuple)].void
}

test("Write should exist for option of some fancy types") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Write[Option[Woozle]].void
Write[Option[(Woozle, String)]].void
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/test/scala/doobie/issue/780.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import scala.annotation.nowarn

@nowarn("msg=.*(Foo is never used|(U|u)nused).*")
class `780` extends munit.FunSuite {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

test("deriving instances should work correctly for Write from class scope") {
class Foo[A: Write, B: Write] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package doobie.util

import cats.data.NonEmptyList
import doobie.implicits.{*, given}
import doobie.implicits.*
import cats.effect.IO
import doobie.{Transactor, Fragment, Fragments}

Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/test/scala/doobie/util/GetSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GetSuite extends munit.FunSuite with GetSuitePlatform {
}

test("Get should be auto derived for unary products") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Get[X].void
Get[Q].void
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/test/scala/doobie/util/PutSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PutSuite extends munit.FunSuite with PutSuitePlatform {
}

test("Put should be auto derived for unary products") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Put[X].void
Put[Q].void
Expand Down
10 changes: 5 additions & 5 deletions modules/core/src/test/scala/doobie/util/ReadSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ReadSuite extends munit.FunSuite with ReadSuitePlatform {
)

test("Read should exist for some fancy types") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Read[Int].void
Read[(Int, Int)].void
Expand Down Expand Up @@ -55,7 +55,7 @@ class ReadSuite extends munit.FunSuite with ReadSuitePlatform {
}

test("Read is still auto derived for tuples when import is present (no ambiguous implicits)") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*
Read[(Int, Int)].void
Read[(Int, Int, String)].void
Read[(Int, (Int, String))].void
Expand Down Expand Up @@ -111,7 +111,7 @@ class ReadSuite extends munit.FunSuite with ReadSuitePlatform {
}

test("Read should exist for option of some fancy types") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Read[Option[Int]].void
Read[Option[(Int, Int)]].void
Expand All @@ -123,14 +123,14 @@ class ReadSuite extends munit.FunSuite with ReadSuitePlatform {
}

test("Read should exist for option of Unit") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Read[Option[Unit]].void
assertEquals(Read[Option[(Int, Unit)]].length, 1).void
}

test("Read should select multi-column instance by default") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

assertEquals(Read[LenStr1].length, 2).void
}
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/test/scala/doobie/util/WriteSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WriteSuite extends munit.FunSuite with WriteSuitePlatform {
)

test("Write should exist for some fancy types") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Write[Int].void
Write[(Int, Int)].void
Expand All @@ -44,7 +44,7 @@ class WriteSuite extends munit.FunSuite with WriteSuitePlatform {
}

test("Write is still auto derived for tuples when import is present (no ambiguous implicits) ") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*
Write[(Int, Int)].void
Write[(Int, Int, String)].void
Write[(Int, (Int, String))].void
Expand Down Expand Up @@ -121,14 +121,14 @@ class WriteSuite extends munit.FunSuite with WriteSuitePlatform {
}

test("Write should exist for Unit") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Write[Unit].void
assertEquals(Write[(Int, Unit)].length, 1)
}

test("Write should exist for option of some fancy types") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Write[Option[Int]].void
Write[Option[(Int, Int)]].void
Expand All @@ -138,14 +138,14 @@ class WriteSuite extends munit.FunSuite with WriteSuitePlatform {
}

test("Write should exist for option of Unit") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

Write[Option[Unit]].void
assertEquals(Write[Option[(Int, Unit)]].length, 1)
}

test("Write should select multi-column instance by default") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

assertEquals(Write[LenStr1].length, 2)
}
Expand Down
4 changes: 2 additions & 2 deletions modules/munit/src/test/scala/doobie/munit/CheckerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait CheckerChecks[M[_]] extends FunSuite with Checker[M] {
test("fail".fail) { check(sql"select 1".query[String]) }

test("trivial case-class") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

check(sql"select 1".query[CheckerChecks.Foo[cats.Id]])
}
Expand All @@ -47,7 +47,7 @@ trait CheckerChecks[M[_]] extends FunSuite with Checker[M] {
}

test("Read should select correct columns for checking when combined with `ap`") {
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

val readInt = Read[(Int, Int)]
val readIntToInt: Read[Tuple2[Int, Int] => String] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait CheckerChecks[M[_]] extends Specification with Checker[M] {

// Abstract type parameters should be handled correctly
{
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

final case class Foo[F[_]](x: Int)
check(sql"select 1".query[Foo[Id]]).void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object CheckerTests extends IOSuite with IOChecker {
final case class Foo[F[_]](x: Int)

test("trivial case-class") { implicit transactor =>
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

check(sql"select 1".query[Foo[cats.Id]])
}
Expand All @@ -54,7 +54,7 @@ object CheckerTests extends IOSuite with IOChecker {
}

test("Read should select correct columns for checking when combined with `ap`") { implicit transactor =>
import doobie.generic.auto.{given, *}
import doobie.generic.auto.*

val readInt = Read[(Int, Int)]
val readIntToInt: Read[Tuple2[Int, Int] => String] =
Expand Down

0 comments on commit 641c1eb

Please sign in to comment.