Skip to content
This repository was archived by the owner on Nov 5, 2022. It is now read-only.

Commit ee59e5a

Browse files
authored
Add LiftIO to IO (#58)
* add liftIO to IO * add sealed qualifer back to MonadIO * format * make liftIO a little nicer * fix comment * fix small typo
1 parent 9f17e77 commit ee59e5a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ioeffect/src/main/scala/scalaz/ioeffect/IO.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ package scalaz.ioeffect
33

44
import scala.annotation.switch
55
import scala.concurrent.duration._
6-
import scalaz.{ -\/, @@, \/, \/-, unused, Maybe }
6+
import scalaz.{ -\/, @@, \/, \/-, unused, Maybe, Monad }
77
import scalaz.syntax.either._
88
import scalaz.ioeffect.Errors._
9-
import scalaz.ioeffect.Errors.TerminatedException
109
import scalaz.Liskov.<~<
1110
import scalaz.Tags.Parallel
1211

@@ -527,6 +526,12 @@ sealed abstract class IO[E, A] { self =>
527526
final def fold[E2, B](err: E => B, succ: A => B): IO[E2, B] =
528527
self.attempt[E2].map(_.fold(err, succ))
529528

529+
/**
530+
* For some monad F and some error type E, lift this IO
531+
* into F if there is a monadIO instance for F
532+
*/
533+
final def liftIO[F[_]: Monad](implicit M: MonadIO[F, E]): F[A] = M.liftIO(self)
534+
530535
/**
531536
* An integer that identifies the term in the `IO` sum type to which this
532537
* instance belongs (e.g. `IO.Tags.Point`).

ioeffect/src/main/scala/scalaz/ioeffect/MonadIOInstances.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
package scalaz.ioeffect
1+
package scalaz
2+
package ioeffect
23

34
import scalaz._
45
import Scalaz._

0 commit comments

Comments
 (0)