Skip to content

Commit

Permalink
rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
jatcwang committed Jul 21, 2024
1 parent bf60306 commit 598bcd4
Show file tree
Hide file tree
Showing 176 changed files with 680 additions and 679 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ lazy val commonSettings =
// (We need "-source:future" for for comprehension irrefutable pattern on Scala 3)
// compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
).filterNot(_ => tlIsScala3.value),
// scalacOptions ++= Seq("-rewrite", "-source:future-migration").filter(_ => tlIsScala3.value),

// MUnit
libraryDependencies ++= Seq(
Expand Down
6 changes: 3 additions & 3 deletions modules/bench/src/main/scala/doobie/bench/select.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
package doobie.bench

import cats.effect.IO
import doobie._, doobie.implicits._
import doobie.*, doobie.implicits.*
import java.sql.DriverManager
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.annotations.*

object shared {

Expand All @@ -21,7 +21,7 @@ object shared {
}

class bench {
import shared._
import shared.*
import cats.effect.unsafe.implicits.global

// Baseline hand-written JDBC code
Expand Down
14 changes: 7 additions & 7 deletions modules/bench/src/main/scala/doobie/bench/text.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

package doobie.bench

import cats.syntax.all._
import doobie._
import doobie.implicits._
import doobie.postgres.implicits._
import fs2._
import org.openjdk.jmh.annotations._
import cats.syntax.all.*
import doobie.*
import doobie.implicits.*
import doobie.postgres.implicits.*
import fs2.*
import org.openjdk.jmh.annotations.*

final case class Person(name: String, age: Int)

class text {
import shared._
import shared.*
import cats.effect.unsafe.implicits.global

def people(n: Int): List[Person] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

package doobie.util

import java.{util => ju}
import java.{util as ju}
import scala.collection.mutable
import scala.collection.immutable.Map
import scala.jdk.CollectionConverters._
import scala.jdk.CollectionConverters.*

package object compat {
type =:=[From, To] = scala.=:=[From, To]
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/main/scala-3/util/ReadPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait ReadPlatform:

// Derivation base case for product types (1-element)
given productBase[H](
using H: Read[H] OrElse MkRead[H]
using H: Read[H] `OrElse` MkRead[H]
): MkRead[H *: EmptyTuple] = {
val head = H.unify
new MkRead(
Expand All @@ -45,7 +45,7 @@ trait ReadPlatform:
// Read for head and tail.
given product[H, T <: Tuple](
using
H: Read[H] OrElse MkRead[H],
H: Read[H] `OrElse` MkRead[H],
T: MkRead[T]
): MkRead[H *: T] = {
val head = H.unify
Expand All @@ -57,7 +57,7 @@ trait ReadPlatform:
}

given optProductBase[H](
using H: Read[Option[H]] OrElse MkRead[Option[H]]
using H: Read[Option[H]] `OrElse` MkRead[Option[H]]
): MkRead[Option[H *: EmptyTuple]] = {
val head = H.unify
MkRead[Option[H *: EmptyTuple]](
Expand All @@ -68,7 +68,7 @@ trait ReadPlatform:

given optProduct[H, T <: Tuple](
using
H: Read[Option[H]] OrElse MkRead[Option[H]],
H: Read[Option[H]] `OrElse` MkRead[Option[H]],
T: MkRead[Option[T]]
): MkRead[Option[H *: T]] = {
val head = H.unify
Expand All @@ -84,7 +84,7 @@ trait ReadPlatform:
}

given optProductOptBase[H](
using H: Read[Option[H]] OrElse MkRead[Option[H]]
using H: Read[Option[H]] `OrElse` MkRead[Option[H]]
): MkRead[Option[Option[H] *: EmptyTuple]] = {
val head = H.unify

Expand All @@ -96,7 +96,7 @@ trait ReadPlatform:

given optProductOpt[H, T <: Tuple](
using
H: Read[Option[H]] OrElse MkRead[Option[H]],
H: Read[Option[H]] `OrElse` MkRead[Option[H]],
T: MkRead[Option[T]]
): MkRead[Option[Option[H] *: T]] = {
val head = H.unify
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/main/scala-3/util/WritePlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait WritePlatform:

// Derivation base case for product types (1-element)
given productBase[H](
using H: Write[H] OrElse MkWrite[H]
using H: Write[H] `OrElse` MkWrite[H]
): MkWrite[H *: EmptyTuple] = {
val head = H.unify
MkWrite(
Expand All @@ -47,7 +47,7 @@ trait WritePlatform:
// Derivation inductive case for product types
given product[H, T <: Tuple](
using
H: Write[H] OrElse MkWrite[H],
H: Write[H] `OrElse` MkWrite[H],
T: MkWrite[T]
): MkWrite[H *: T] = {
val head = H.unify
Expand All @@ -62,7 +62,7 @@ trait WritePlatform:

// Derivation base case for Option of product types (1-element)
given optProductBase[H](
using H: Write[Option[H]] OrElse MkWrite[Option[H]]
using H: Write[Option[H]] `OrElse` MkWrite[Option[H]]
): MkWrite[Option[H *: EmptyTuple]] = {
val head = H.unify

Expand All @@ -77,7 +77,7 @@ trait WritePlatform:
// Write[Option[H]], Write[Option[T]] implies Write[Option[H *: T]]
given optProduct[H, T <: Tuple](
using
H: Write[Option[H]] OrElse MkWrite[Option[H]],
H: Write[Option[H]] `OrElse` MkWrite[Option[H]],
T: MkWrite[Option[T]]
): MkWrite[Option[H *: T]] =
val head = H.unify
Expand All @@ -100,7 +100,7 @@ trait WritePlatform:

// Derivation base case for Option of product types (where the head element is Option)
given optProductOptBase[H](
using H: Write[Option[H]] OrElse MkWrite[Option[H]]
using H: Write[Option[H]] `OrElse` MkWrite[Option[H]]
): MkWrite[Option[Option[H] *: EmptyTuple]] = {
val head = H.unify

Expand All @@ -115,7 +115,7 @@ trait WritePlatform:
// Write[Option[H]], Write[Option[T]] implies Write[Option[Option[H] *: T]]
given optProductOpt[H, T <: Tuple](
using
H: Write[Option[H]] OrElse MkWrite[Option[H]],
H: Write[Option[H]] `OrElse` MkWrite[Option[H]],
T: MkWrite[Option[T]]
): MkWrite[Option[Option[H] *: T]] =
val head = H.unify
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/main/scala-3/util/shapeless/OrElse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ final class Secondary[+B](value: => B) extends OrElse[Nothing, B] {
}

object OrElse extends OrElse0 {
implicit def primary[A, B](implicit a: A): A OrElse B = new Primary(a)
implicit def primary[A, B](implicit a: A): A `OrElse` B = new Primary(a)
}

private[shapeless] abstract class OrElse0 {
implicit def secondary[A, B](implicit b: => B): A OrElse B = new Secondary(b)
implicit def secondary[A, B](implicit b: => B): A `OrElse` B = new Secondary(b)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

package doobie.enumerated

import java.sql.Statement._
import java.sql.Statement.*

import cats.kernel.Eq
import cats.kernel.instances.int._
import cats.kernel.instances.int.*

/** @group Types */
sealed abstract class AutoGeneratedKeys(val toInt: Int) extends Product with Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

package doobie.enumerated

import doobie.util.invariant._
import doobie.util.invariant.*

import java.sql.ResultSetMetaData._
import java.sql.ResultSetMetaData.*

import cats.ApplicativeError
import cats.kernel.Eq
import cats.kernel.instances.int._
import cats.kernel.instances.int.*

/** @group Types */
sealed abstract class ColumnNullable(val toInt: Int) extends Product with Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

package doobie.enumerated

import doobie.util.invariant._
import doobie.util.invariant.*

import java.sql.ResultSet._
import java.sql.ResultSet.*

import cats.ApplicativeError
import cats.kernel.Eq
import cats.kernel.instances.int._
import cats.kernel.instances.int.*

/** @group Types */
sealed abstract class FetchDirection(val toInt: Int) extends Product with Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

package doobie.enumerated

import doobie.util.invariant._
import doobie.util.invariant.*

import java.sql.ResultSet._
import java.sql.ResultSet.*

import cats.ApplicativeError
import cats.kernel.Eq
import cats.kernel.instances.int._
import cats.kernel.instances.int.*

/** @group Types */
sealed abstract class Holdability(val toInt: Int) extends Product with Serializable
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/main/scala/doobie/enumerated/jdbctype.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

package doobie.enumerated

import java.sql.Types._
import java.sql.Types.*

import cats.Show
import cats.kernel.Order
import cats.kernel.instances.int._
import cats.kernel.instances.int.*

/** @group Types */
sealed abstract class JdbcType(val toInt: Int) extends Product with Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

package doobie.enumerated

import doobie.util.invariant._
import doobie.util.invariant.*

import java.sql.ParameterMetaData._
import java.sql.ParameterMetaData.*

import cats.ApplicativeError
import cats.kernel.Eq
import cats.kernel.instances.int._
import cats.kernel.instances.int.*

/** @group Types */
sealed abstract class ParameterMode(val toInt: Int) extends Product with Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

package doobie.enumerated

import doobie.util.invariant._
import doobie.util.invariant.*

import java.sql.ParameterMetaData._
import java.sql.ParameterMetaData.*

import cats.ApplicativeError
import cats.kernel.Eq
import cats.kernel.instances.int._
import cats.kernel.instances.int.*

/** @group Types */
sealed abstract class ParameterNullable(val toInt: Int) extends Product with Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

package doobie.enumerated

import doobie.util.invariant._
import doobie.util.invariant.*

import java.sql.ResultSet._
import java.sql.ResultSet.*

import cats.ApplicativeError
import cats.kernel.Eq
import cats.kernel.instances.int._
import cats.kernel.instances.int.*

/** @group Types */
sealed abstract class ResultSetConcurrency(val toInt: Int) extends Product with Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

package doobie.enumerated

import doobie.util.invariant._
import doobie.util.invariant.*

import java.sql.ResultSet._
import java.sql.ResultSet.*

import cats.ApplicativeError
import cats.kernel.Eq
import cats.kernel.instances.int._
import cats.kernel.instances.int.*

/** @group Types */
sealed abstract class ResultSetType(val toInt: Int) extends Product with Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

package doobie.enumerated

import doobie.util.invariant._
import doobie.util.invariant.*

import java.sql.Connection._
import java.sql.Connection.*

import cats.{ApplicativeError, Show}
import cats.kernel.Eq
import cats.kernel.instances.int._
import cats.kernel.instances.int.*

/** @group Types */
sealed abstract class TransactionIsolation(val toInt: Int) extends Product with Serializable
Expand Down
Loading

0 comments on commit 598bcd4

Please sign in to comment.