Adding Applicative/Functor instances to all Monads in GHC

David Luposchainsky dluposchainsky at googlemail.com
Thu May 16 13:33:44 CEST 2013


Hello everyone,

I recently went through GHC's source, and discovered there are quite a
few instances of Monad that don't have Functor or Applicative instances.
Fixing this is very easy by adding the standard instances (pure = return
etc.), and will not break code.

There is one exception to this: Hoopl defines its own (<*>). However,
since it does not seem to have any packages depend on it otherwise,
renaming this operator is also easily done (the thing is only used ten
times or so). I called it (<*|*>) to complement (|*><*|), but naming
should be the least important issue here.

Small piece of backstory:
The idea behind this is making GHC future-proof for changing Applicative
to be a superclass of Monad. However, I think adding the Applicative
instances is a good idea regardless of whether this will ever happen, so
that's the only thing I'm proposing right now.

Greetings,
David



More information about the Libraries mailing list