ekmett / hkd

higher-kinded data
Other
30 stars 2 forks source link

change method (i)ftraverse to (i)ftraverseMap? #6

Closed wygulmage closed 2 years ago

wygulmage commented 2 years ago

ftraverse :: (Applicative m)=> (forall x. f x -> m (g x)) -> t f -> m (t g) ftraverseMap :: (Applicative m)=> (t g -> r) -> (forall x. f x -> m (g x)) -> t f -> m r

Although it is more complicated, ftraverseMap gives slightly better ergonomics when defining instances (e.g. ftraverseMap g f = ftraverseMap (g . to1) f . from1 rather than `ftraverse f = fmap to1 . ftraverse f . from1). For lifted tuples the ergonomics are worse in proportion to the size of the tuple.

This likely eliminates the need for confusing in the generic definition because the map over the Applicative is already fused. It should also allow GeneralizedNewtypeDeriving.

wygulmage commented 2 years ago

The use of 'confused' was confusing me, but its properties probably make it better to keep things as they are, so I'm closing this PR.