In this answer I made up on the spot something which looks a bit like a \"higher order Traversable
\": like Traversable
but for functors from the ca
In first order, we have sequence = traverse id
.
Here the first argument of htraverse
has type forall x. f x -> a (g x)
, we can't have id
, but we can try with an isomorphism instead. For f x
to be isomorphic to a (g x)
, we can pick f ~ Compose a g
.
htraverse = hsequence . hmap (Compose . eta)
hsequence :: Applicative a => t (Compose a g) -> a (t g)
hsequence = htraverse getCompose