instance visibility

Claus Reinke claus.reinke at
Fri Sep 26 17:46:52 EDT 2008

> On Fri, Sep 26, 2008 at 2:37 PM, Claus Reinke <claus.reinke at> wrote:
>> It seems that the ultimate offender is Control.Applicative, which
>> imports Control.Monad.Instances() for no other reason than to
>> infect its importers. That then propagates all over the place.
> Control.Applicative defines Applicative instances for (->) and (,).
> Doing so requires Functor instances for (->) and (,), which are
> defined in Control.Monad.Instances.

Wouldn't it be possible just to delay the instance selection?

    instance Applicative ((->) a) where

would become

    instance Functor ((->)a) => Applicative ((->) a) where

But, that code doesn't seem to require the instances? Only I just
noticed that Control.Applicative imports Control.Arrow, which
imports Control.Monad.Fix, which imports Control.Monad.Instances.

We can apply the constraint delay in Control.Monad.Fix, making

    instance Functor ((->)r) => MonadFix ((->)r)

but that requires 

    {-# LANGUAGE UndecidableInstances #-}
    {-# LANGUAGE FlexibleContexts #-}

(the need for the former highlights another language limitation..)

> I suppose one solution would be to move the Applicative instances for
> (->) and (,) to Control.Monad.Instances.
> -- 
> Dave Menendez <dave at>
> <>

More information about the Libraries mailing list