Proposal: add liftA4 and liftA5 to match liftM4 and liftM5

Henning Thielemann lemming at henning-thielemann.de
Fri Nov 7 10:30:59 UTC 2014


On Fri, 7 Nov 2014, Andreas Abel wrote:

> Agreed.  I never use liftMx or liftAx and when I see them in old code, I 
> replace them by <$> and <*>.
>
> Anyway, I like the proposal best that changes to constraint on liftM to 
> Applicative, and leaves everything else alone.

Ah no, this would add new stuff that can only be explained by history.


> I hope the same happens for sequence, mapM and the like!
>
>  sequence :: (Applicative m) => [m a] -> m [a]
>  sequence = foldr (\ x xs -> (:) <$> x <*> xs) (pure [])

Actually, this is an example, where liftA2 shows its advantage:

   sequence = foldr (liftA2 (:)) (pure [])

This looks much clearer to me than decoding the mixture of infix and 
uninfixed infix operators. It simply says, that 'sequence' is like 'id = 
foldr (:) []' but with everything lifted to an applicative functor.


More information about the Libraries mailing list