Last active
May 14, 2020 01:26
-
-
Save lu4nm3/9228caece9ecee855469c42680e38005 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
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