Control.Lens.Tutorial says:
type Traversal' a b = forall f . Applicative f => (b -> f b) -> (a -> f a) type Lens' a b = forall f . Functor f => (b -> f b) -> (a -> f a)Notice that the only difference between a Lens' and a Traversal' is the type class constraint. A Lens' has a Functor constraint and Traversal' has an Applicative constraint. This means that any Lens' is automatically also a valid Traversal' (since Functor is a superclass of Applicative).
I simply don't follow the logical sequence here. We know that every Applicative is a Functor. From this, should it not follow, if at all, that every Traversal' is a Lens'? The tutorial however reaches the converse conclusion.
A
Lens'works for all functors, which includes all applicative functors, so if a functiongis aLens', thengis also aTraversal'.A
Traversal'works for all applicative functors, but not necessarily all functors. So if a functionhis aTraversal', it is not necessarily aLens'.(I'm not the one to describe this formally, but to me at least, it looks like the types are "contravariant" in their constraints.
Lens'is a subtype ofTraversal'precisely becauseFunctoris a superclass ofApplicative.)