Skip to content

Instantly share code, notes, and snippets.

@seanparsons
Last active December 20, 2015 09:58
Show Gist options
  • Save seanparsons/6111532 to your computer and use it in GitHub Desktop.
Save seanparsons/6111532 to your computer and use it in GitHub Desktop.
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] = {
val tFromTriple: ((T, U, V)) => T = _._1
val tuFromTriple: ((T, U, V)) => (T, U) = tup => (tup._1, tup._2)
val vFromTriple: ((T, U, V)) => V = _._3
for {
_ <- actionOne().local(tFromTriple)
_ <- actionTwo().local(tFromTriple)
_ <- actionThree().local(tFromTriple)
_ <- actionFour().local(tuFromTriple)
_ <- actionFive().local(tFromTriple)
_ <- actionSix().local(vFromTriple)
} yield ()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment