Skip to content

Instantly share code, notes, and snippets.

@eamelink
Created November 16, 2015 12:05
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 eamelink/df52be4b71c76992bfa2 to your computer and use it in GitHub Desktop.
Save eamelink/df52be4b71c76992bfa2 to your computer and use it in GitHub Desktop.
Traverse and TraverseU
val myList = List("foo")
val myFun: (String) => EitherT[Future, Exception, Int] = (in: String) => EitherT { Future { try { \/-(in.toInt) } catch { case NonFatal(e: Exception) => -\/(e) } }}
// Regular traverse
Traverse[List].traverse[({type G[A]=EitherT[Future,Exception,A]})#G, String, Int](myList)(myFun)
// TraverseU to the rescue!
Traverse[List].traverseU(myList)(myFun)
// Pimpin' to the rescue!
myList.traverseU(myFun)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment