Last active
May 14, 2020 01:26
-
-
Save lu4nm3/381574556997439b642809402fd11836 to your computer and use it in GitHub Desktop.
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 characters
def createMonadReader[E](value: E): IO[MonadReader[IO, E]] = { | |
for { | |
input <- Ref.of[IO, E](value) | |
} yield new MonadReader[IO, E] { | |
val monad: Monad[IO] = Monad[IO] | |
def ask: IO[E] = input.get | |
def reader[A](f: E => IO[A]): IO[A] = ask.flatMap(f) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment