Created
November 16, 2015 12:05
-
-
Save eamelink/df52be4b71c76992bfa2 to your computer and use it in GitHub Desktop.
Traverse and TraverseU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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