Last active
May 14, 2020 02:07
-
-
Save lu4nm3/a54c00566823d978dea3b587b3db1cb3 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 program[F[_]](R: MonadReader[F, Env], | |
W: MonadWriter[F, Vector[SystemState]], | |
S: MonadState[F, SystemState]): F[(Vector[SystemState], SystemState)] = { | |
implicit val M: Monad[F] = R.monad | |
for { | |
status <- R.reader(getServerStatus[F]()) | |
state <- S.get | |
env <- R.ask | |
updatedState = SystemState(state.value + (env -> status)) | |
_ <- S.set(updatedState) | |
_ <- W.tell(Vector(updatedState)) | |
_ <- status match { | |
case Degraded | Unavailable => R.reader(alertAdmin[F](status)) | |
case _ => M.unit | |
} | |
logs <- W.logs | |
finalState <- S.get | |
} yield (logs, finalState) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment