Skip to content

Instantly share code, notes, and snippets.

@markhibberd
Created February 7, 2014 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markhibberd/8857945 to your computer and use it in GitHub Desktop.
Save markhibberd/8857945 to your computer and use it in GitHub Desktop.
def x[M[_]: MonadPlus, A, B](xs: List[A], f: A => M[B]): M[B] =
xs.foldLeft(implicitly[MonadPlus[M]].empty[B])((acc, a) => implicitly[MonadPlus[M]].plus(acc, f(a)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment