Skip to content

Instantly share code, notes, and snippets.

@tzachz
Created July 24, 2018 22:05
Show Gist options
  • Save tzachz/4dbd8054426e7e434b885dbb800f8128 to your computer and use it in GitHub Desktop.
Save tzachz/4dbd8054426e7e434b885dbb800f8128 to your computer and use it in GitHub Desktop.
CompositionFinal
// Now we can count on flapMap to do the magic!
def processRequest(a: A): Future[Result] = {
for {
b <- f1(a)
c <- flip(b.map(f2))
d <- flip(c.map(f3))
r <- flip(d.map(f4))
} yield r.getOrElse[Result](r.left.get)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment