Last active
June 7, 2019 05:15
-
-
Save SystemFw/5b36f7ded2b9377e99d475937345fa2f to your computer and use it in GitHub Desktop.
Revisions
-
SystemFw revised this gist
Oct 25, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -43,7 +43,7 @@ object Results { implicit def gen[T, L <: HList, O <: HList]( implicit gen: Generic.Aux[T, L], v: Lazy[Results.Aux[L, O]], ev: Sequencer.Aux[O, Kleisli[IO, DB, ?], L]): Results.Aux[T, Kleisli[IO, DB, T]] = instance(v.value.value.sequence.map(gen.from)) } -
SystemFw revised this gist
Oct 17, 2017 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -36,10 +36,10 @@ object Results { implicit def hnil: Results.Aux[HNil, HNil] = instance(HNil) implicit def hcons[H, T <: HList, R <: HList, O]( implicit g: Lazy[Results.Aux[H, O]], n: Results.Aux[T, R]): Results.Aux[H :: T, O :: R] = instance(g.value.value :: n.value) implicit def gen[T, L <: HList, O <: HList]( implicit gen: Generic.Aux[T, L], -
SystemFw revised this gist
Oct 11, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,9 @@ import cats.sequence._ //requires kittens import cats.effect.IO //requires cats-effect // ofc, uses "-Ypartial-unification" and kind-projector case class Result() // replace with the JDBC equivalent case class DB(val r: Result) { def nextInt: IO[Int] = ??? //IO(g.nextInt) def nextDouble: IO[Double] = ??? def nextFloat: IO[Float] = ??? -
SystemFw revised this gist
Oct 10, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import shapeless._ // requires.shapeless import cats._, implicits._, data.Kleisli // requires.cats import cats.sequence._ //requires kittens import cats.effect.IO //requires cats-effect // ofc, uses "-Ypartial-unification" and kind-projector case class GetResult() // replace with slick's -
SystemFw revised this gist
Oct 10, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -24,10 +24,10 @@ object Results { def value = v } implicit def ints: Results.Aux[Int, Kleisli[IO, DB, Int]] = instance(Kleisli(r => r.nextInt)) implicit def doubles: Results.Aux[Double, Kleisli[IO, DB, Double]] = instance(Kleisli(r => r.nextDouble)) implicit def floats: Results.Aux[Float, Kleisli[IO, DB, Float]] = -
SystemFw created this gist
Oct 10, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ import shapeless._ // requires.shapeless import cats._, implicits._, data.Kleisli // requires.cats import cats.sequence._ //requires kittens import cats.effect.IO //requires cats-effect case class GetResult() // replace with slick's case class DB(val g: GetResult) { def nextInt: IO[Int] = ??? //IO(g.nextInt) def nextDouble: IO[Double] = ??? def nextFloat: IO[Float] = ??? } trait Results[I] { type Out def value: Out } object Results { def of[T](implicit ev: Results[T]): ev.Out = ev.value type Aux[I, O] = Results[I] { type Out = O } def instance[I, O](v: O): Results.Aux[I, O] = new Results[I] { type Out = O def value = v } implicit def ints: Results.Aux[Int, Kleisli[IO, DB,Int]] = instance(Kleisli(r => r.nextInt)) implicit def doubles: Results.Aux[Double, Kleisli[IO, DB,Double]] = instance(Kleisli(r => r.nextDouble)) implicit def floats: Results.Aux[Float, Kleisli[IO, DB, Float]] = instance(Kleisli(r => r.nextFloat)) implicit def hnil: Results.Aux[HNil, HNil] = instance(HNil) implicit def hcons[H, T <: HList, R <: HList]( implicit g: Results[H], n: Results.Aux[T, R]): Results.Aux[H :: T, g.Out :: R] = instance(g.value :: n.value) implicit def gen[T, L <: HList, O <: HList]( implicit gen: Generic.Aux[T, L], v: Results.Aux[L, O], ev: Sequencer.Aux[O, Kleisli[IO, DB, ?], L]): Results.Aux[T, Kleisli[IO, DB, T]] = instance(v.value.sequence.map(gen.from)) } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ object Test { case class Foo(a: Int, b: Double) def db: DB = ??? val d: IO[Foo] = Results.of[Foo].run(db) }