Adding Applicative/Functor instances to all Monads in GHC

Ian Lynagh ian at well-typed.com
Fri May 17 19:55:47 CEST 2013


On Thu, May 16, 2013 at 01:33:44PM +0200, David Luposchainsky wrote:
> 
> I recently went through GHC's source,

If you're talking about GHC itself, rather than the libraries that come
with it, then this would be better discussed on the ghc-devs@ list.

> and discovered there are quite a
> few instances of Monad that don't have Functor or Applicative instances.
> 
> Small piece of backstory:
> The idea behind this is making GHC future-proof for changing Applicative
> to be a superclass of Monad.

I don't think that it helps with this, for 2 reasons:

1. The next time someone adds a Monad, the chances are that they will
   not think to add the other instances

2. You can't build GHC version X with GHC version Y, where Y > X.
   Therefore should Applicative become a superclass of Monad, any GHC
   that has that change would not be able to compile older GHCs (which
   perhaps are missing Applicative instances) anyway.

> 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.

I'm a bit ambivalent about this. On the one hand, I wouldn't object to
adding instances that are actually useful, but on the other we've
currently got problems with the number of symbols in the GHC package DLL
on Windows, and I'm not sure anything would be gained by adding
instances in many cases.


Thanks
Ian




More information about the Libraries mailing list