Skip to content

Instantly share code, notes, and snippets.

@seanparsons
Created August 2, 2013 15:54
Show Gist options
  • Save seanparsons/6141023 to your computer and use it in GitHub Desktop.
Save seanparsons/6141023 to your computer and use it in GitHub Desktop.
Prettier ReaderT handling code.
def doThing[M[+_]: Monad, T, U, V]
(actionOne: () => ReaderT[M, T, Unit],
actionTwo: () => ReaderT[M, T, Unit],
actionThree: () => ReaderT[M, T, Unit],
actionFour: () => ReaderT[M, (T, U), Unit],
actionFive: () => ReaderT[M, T, Unit,
actionSix: () => ReaderT[M, V, Unit])
(): ReaderT[M, (T, U, V), Unit] = {
for {
_ <- actionOne().localFrom[(T, U, V)]
_ <- actionTwo().localFrom[(T, U, V)]
_ <- actionThree().localFrom[(T, U, V)]
_ <- actionFour().localFrom[(T, U, V)]
_ <- actionFive().localFrom[(T, U, V)]
_ <- actionSix().localFrom[(T, U, V)]
} yield ()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment