[Haskell-beginners] Trying to prove Applicative is superclass of Functor, etc

Dániel Arató exitconsole at gmail.com
Fri Apr 29 09:23:23 UTC 2016


Applicative is actually a *sub*class of Functor. :)

> Hi, well aware it's trivial so I'll be terse: do we have?:
>> fmap = <*> . pure

That's right. You have to wrap the "<*>" in parantheses though.

> So we could write for example
>> liftA2 f fa fb =  f <$> fa <*> fb
> this way?:
>> liftA2 f fa fb = pure f <*> fa <*> fb <*>

You don't need the last "<*>", but other than that yeah, that's exactly right.

> Incidentally, do we have?:
>> liftA == liftM == fmap

Correct. The Prelude defines liftM in terms of do notation though for
reasons that escape me. But it's basically just fmap.

Daniel


More information about the Beginners mailing list