Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. sealed trait Free[F[_], A] {
  2.  
  3. def flatMap[B](f: A => Free[F, B]): Free[F, B] = this match {
  4. case Return(a) => f(a)
  5. case FlatMap(sub, cont) => FlatMap(sub, cont andThen (_ flatMap f))
  6. }
  7.  
  8. def map[B](f: A => B): Free[F, B] = flatMap(a => Return(f(a)))
  9.  
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement