Skip to content

Instantly share code, notes, and snippets.

@lu4nm3
Last active May 14, 2020 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lu4nm3/381574556997439b642809402fd11836 to your computer and use it in GitHub Desktop.
Save lu4nm3/381574556997439b642809402fd11836 to your computer and use it in GitHub Desktop.
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