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/9228caece9ecee855469c42680e38005 to your computer and use it in GitHub Desktop.
Save lu4nm3/9228caece9ecee855469c42680e38005 to your computer and use it in GitHub Desktop.
val getJobStatus: Config => IO[Status] = ???
def sendAlert(status: Status): Config => IO[Unit] = ???
// ReaderT[F[_], E, A] is a type alias of Kleisli[F, E, A] so we can use the Kleisli constructor to wrap our functions
val getJobStatusR: ReaderT[IO, Config, Status] = Kleisli(getJobStatus)
def sendAlertR(status: Status): ReaderT[IO, Config, Unit] = Kleisli(sendEmail(status))
val program: ReaderT[IO, Config, Unit] = for {
status <- getJobStatusR
_ <- sendAlertR(status, user)
} yield ()
program.run(Config("127.0.0.1:8080")) // IO[Unit]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment