-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continuational representation of ConnectionIO (#698)
* Continuational representation of ConnectionIO * fix import * revert `contextual` (still deprecated) * def -> val * rework implicits * make Txr 2-parametric, deprecate more stuff
- Loading branch information
1 parent
0771ccc
commit b6d67ff
Showing
13 changed files
with
237 additions
and
119 deletions.
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
...oobie/src/main/scala-2.12/tofu/doobie/instances/DoobieImplicitsScalaVersionSpecific.scala
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...oobie/src/main/scala-2.13/tofu/doobie/instances/DoobieImplicitsScalaVersionSpecific.scala
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
modules/doobie/src/main/scala/tofu/doobie/ConnectionCIO.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,18 @@ | ||
package tofu.doobie | ||
|
||
import cats.data.Kleisli | ||
import cats.~> | ||
import doobie.ConnectionIO | ||
import tofu.kernel.types.AnyK | ||
|
||
object ConnectionCIO { | ||
trait Cont[F[_]] extends (ConnectionIO ~> F) | ||
object Cont { | ||
private val liftConnectionIOToConnectionCIOAny: LiftConnectionIO[ConnectionCIO[AnyK, *]] = | ||
new LiftConnectionIO[ConnectionCIO[AnyK, *]] { | ||
def lift[A](ca: ConnectionIO[A]): ConnectionCIO[AnyK, A] = Kleisli(k => k(ca)) | ||
} | ||
@inline final implicit def liftConnectionIOToConnectionCIO[F[_]]: LiftConnectionIO[ConnectionCIO[F, *]] = | ||
liftConnectionIOToConnectionCIOAny.asInstanceOf[LiftConnectionIO[ConnectionCIO[F, *]]] | ||
} | ||
} |
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
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
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,14 +1,17 @@ | ||
package tofu | ||
|
||
import _root_.doobie.ConnectionIO | ||
import cats.data.ReaderT | ||
import cats.data.{Kleisli, ReaderT} | ||
import tofu.lift.Lift | ||
|
||
package object doobie { | ||
|
||
/** A contextual database effect with environment of type R. */ | ||
type ConnectionRIO[R, A] = ReaderT[ConnectionIO, R, A] | ||
|
||
/** A continuational form of `ConnectionIO` equivalent to `[x] =>> ConnectionIO ~> F => F[x]`. */ | ||
type ConnectionCIO[F[_], A] = Kleisli[F, ConnectionCIO.Cont[F], A] | ||
|
||
/** A typeclass for lifting `ConnectionIO` into extended database effects such as `ConnectionRIO`. */ | ||
type LiftConnectionIO[DB[_]] = Lift[ConnectionIO, DB] | ||
} |
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
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
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
Oops, something went wrong.