Skip to content

Commit

Permalink
add IO.lift (#1146)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Sep 12, 2018
1 parent f7cca46 commit 56cfec6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions quill-core/src/main/scala/io/getquill/monad/IOMonad.scala
Expand Up @@ -38,6 +38,8 @@ trait IOMonad {

object IO {

def lift[T](result: => Result[T]): IO[T, Effect] = Run(() => result)

def fromTry[T](result: Try[T]): IO[T, Effect] = FromTry(result)

def sequence[A, M[X] <: TraversableOnce[X], E <: Effect](in: M[IO[A, E]])(implicit cbfIOToResult: CanBuildFrom[M[IO[A, E]], Result[A], M[Result[A]]], cbfResultToValue: CanBuildFrom[M[Result[A]], A, M[A]]): IO[M[A], E] =
Expand Down
6 changes: 6 additions & 0 deletions quill-core/src/test/scala/io/getquill/monad/IOMonadSpec.scala
Expand Up @@ -22,6 +22,12 @@ trait IOMonadSpec extends Spec {

"IO companion object" - {

"lift" in {
val t = Success(1)
val io = IO.lift(resultValue(1))
Try(eval(io)) mustEqual t
}

"fromTry" - {
"success" in {
val t = Success(1)
Expand Down

0 comments on commit 56cfec6

Please sign in to comment.