[Haskell-cafe] wierd type errros with MPTCs

Daniel Fischer daniel.is.fischer at web.de
Thu Jan 27 14:55:51 EST 2005


Am Donnerstag, 27. Januar 2005 18:53 schrieb S. Alexander Jacobson:
> This code gives me a Kind error because IVal isn't
> applied to enough type arguments.
>
>        import qualified Set
>
>        class Table table indexVal | indexVal->table where
>            --insertIndex::item->indexVal item -> table item ->table item
>            union::table item -> table item -> table item
>            --union t1 t2 = t1
>
>        data DBTable item = DBTable
>        data IVal item = Name item
>
>        instance Table DBTable (IVal ) where
>
> Weirdly, when I uncomment the insertIndex
> function, things work.  But, if I then uncomment

I'm not sure about this, but I believe that the type-variable indexVal in the 
class definition is defaulted to kind *.
Now IVal has kind * -> *, so the instance declaration doesn't kind-match.
If you uncomment insertIndex, ghc can see that indexVal must have kind * -> *, 
so things work.

> the default implementation of union, I get:
>
>        No instance for (Table DBTable indexVal)
>          arising from use of `Main.$dmunion' at example.hs:13
>        In the definition of `union': union = Main.$dmunion
>        In the definition for method `union'
>        In the instance declaration for `Table DBTable IVal'
>
> I don't know what this error even means.  But it
> goes away if I put the union implementation in the
> instance rather than in the class.
>
I don't see what's wrong there either.
Maybe consulting the user's guide will help.

> Bot these error messages seem unreasonable.  Can
> someone clarify?

Hope,
a) I got it right,
b) it helped.
>
> Note: I am using GHC 6.2.2
>
> -Alex-
>
Daniel


More information about the Haskell-Cafe mailing list