Hey all,

I was playing around with type families, and I have a strange problem.

Suppose we have an alternative to an Either datatype:

> data (:|:) a b = Inl a | Inr b

and a class Ix:

> class Ix i where
>   type IxMap i :: * -> *
>   empty  :: IxMap i [Int]

Now I want to give an instance for (a :|: b):

> instance (Ix l, Ix r) => Ix (l :|: r) where
>   type IxMap (l :|: r) = BiApp (IxMap l) (IxMap r)
>   empty = BiApp empty empty

BiApp is defined as following:

> data BiApp a b c = BiApp (a c) (b c)

However, it looks like the recursive calls to empty can't be unified, I get the following error message:

    Couldn't match expected type `IxMap l'
           against inferred type `IxMap i'
      Expected type: IxMap (l :|: r) [Int]
      Inferred type: BiApp (IxMap i) (IxMap i1) [Int]
    In the expression: BiApp empty empty
    In the definition of `empty': empty = BiApp empty empty

In the inferred type, there should be IxMap l instead of IxMap i, does anybody know what I'm doing wrong?

Thanks,

-chris

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to