I am learning Scalaz and I have a project that already makes use of Scalaz7. Following this question I would like to use the function
sequence[T](l: List[Option[T]]): Option[List[T]]
(not that it is hard to write it myself). But the aforementioned question mentions Scalaz6.
Where to find the sequence function in Scalaz7?
It’s defined in the
scalaz.Traversetype class, where it looks like this:scalaz.syntax.TraverseOpsprovides a version that gets pimped ontoList, sinceListhas aTraverseinstance.You can either import just what you need:
Or everything and the kitchen sink:
And then you can use it like this:
Or if you want exactly the formulation in your question: