Skip to content

Instantly share code, notes, and snippets.

@seanparsons
Created July 16, 2014 17:22
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 seanparsons/f05e5b657a8197986dfa to your computer and use it in GitHub Desktop.
Save seanparsons/f05e5b657a8197986dfa to your computer and use it in GitHub Desktop.
List of failures or successes to a failure or list of successes.
scala> val list = List(1.right[String], "Fail".left[Int], 3.right[String])
list: List[scalaz.\/[String,Int]] = List(\/-(1), -\/(Fail), \/-(3))
scala> list.sequenceU
res1: scalaz.\/[String,List[Int]] = -\/(Fail)
scala> val list = List(1.right[String], 2.right[String], 3.right[String])
list: List[scalaz.\/[String,Int]] = List(\/-(1), \/-(2), \/-(3))
scala> list.sequenceU
res2: scalaz.\/[String,List[Int]] = \/-(List(1, 2, 3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment