GADTs and functional dependencies

Alfonso Acosta alfonso.acosta at gmail.com
Tue Sep 23 12:19:39 EDT 2008


On Tue, Sep 23, 2008 at 6:07 PM, Wolfgang Jeltsch
<g9ks157k at acme.softbase.org> wrote:
> Hello,
>
> please consider the following code:
>
>> {-# LANGUAGE GADTs, MultiParamTypeClasses, FunctionalDependencies #-}
>>
>> data GADT a where
>>
>>     GADT :: GADT ()
>>
>> class Class a b | a -> b
>>
>> instance Class () ()
>>
>> fun :: (Class a b) => GADT a -> b
>> fun GADT = ()
>
> I'd expect this to work but unfortunately, using GHC 6.8.2, it fails with the
> following message:

bear in mind that the only instance you defined is

instance Class () ()

which doesn't involve your GADT at all.

Maybe you meant something like:

instance Class (GADT a) ()

Moreover, your fun cannot typecheck, regardless of using MPTC or
GADTs. The unit constructor, (), has type () and not b.


More information about the Glasgow-haskell-users mailing list