[Haskell-cafe] Why the reluctance to introduce the Functor requirement on Monad?

James Cook mokus at deepbondi.net
Tue Jul 26 13:24:04 CEST 2011


On Jul 25, 2011, at 7:38 PM, Maciej Marcin Piechotka wrote:

> On Mon, 2011-07-25 at 00:11 -0400, August Sodora wrote:
>> Out of (perhaps naive) curiosity, what difficulties does allowing such
>> overriding introduce? Wouldn't the module system prevent the ambiguity
>> of which implementation to use?
>> 
>> August Sodora
>> augsod at gmail.com
>> (201) 280-8138
>> 
> 
> class A a where
>  a :: a
> 
> class A a => B b where
>  b :: b
> 
>  a = b
> 
> class A a => C c where
>  c :: c
> 
>  a = c
> 
> data BC = B | C deriving Show
> 
> instance B BC where
>  b = B
> 
> instance C BC where
>  c = C
> 
> show (a :: BC) == ???
> 


I would imagine this causing a compiler error, such as:

Foo.hs:16:10:
    Duplicate implied instance declarations:
      instance A BC -- Defined at Foo.hs:16:10-13
      instance A BC -- Defined at Foo.hs:19:10-13
    Adding an explicit instance A BC would resolve this ambiguity.





More information about the Haskell-Cafe mailing list