vendredi 19 septembre 2014

The type variable ‘a0’ is ambiguous


Vote count:

0




I don't understand why the following code won't compile:



{-# LANGUAGE GADTs, ScopedTypeVariables #-}

data A = A

class C a where
c :: a -> Bool

instance C A where
c _ = True

data D a where
D :: C a => D a

toBool :: D a -> Bool
toBool D = c (undefined::a)


Here is the error message:



Could not deduce (C a0) arising from a use of ‘c’
from the context (C a)
bound by a pattern with constructor
D :: forall a. C a => D a,
in an equation for ‘toBool’
at test.hs:15:8
The type variable ‘a0’ is ambiguous
Note: there is a potential instance available:
instance C A -- Defined at test.hs:8:10
In the expression: c (undefined :: a)
In an equation for ‘toBool’: toBool D = c (undefined :: a)


Can someone explain what's going on ?                                        



asked 34 secs ago







The type variable ‘a0’ is ambiguous

Aucun commentaire:

Enregistrer un commentaire