Is there a typeclass in Cats or Scalaz that converts between different container types? For example
- Option ~> Try
- Try ~> Future
- Try ~> Either
- Option ~> List
It seems like FunctionK/~>/NaturalTransformation may be what I'm looking for, but there aren't any instances defined for them and I don't know why.
Natural transformations are what you're looking for. They define morphisms between functors (In this case, the
List[A]and theOption[A]type constructors). You can define one using the~>"operator" in Scalaz:Yields:
The
~>is syntatic sugar for the traitNaturalTransformation[-F[_], +G[_]]: