Michael Marte <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in 
gmane.comp.lang.haskell.general:
> *FD> :type let x = (1::Int) in x #+ x #+ x
> let x = (1::Int) in x #+ x #+ x :: (MakeAExp (AExp s) s1) => AExp s1
> 
> It appears to me that ghci generates two phantom types s and s1 and fails to 
> unify them.

Because you may define other MakeAExp instances elsewhere, ghc can't
unify s and s1.  For example, if you were to define

    instance MakeAExp (FDVar s) [s] ...
    instance MakeAExp (AExp [s]) s ...

then s could be [s1] in your type!

You can probably add functional dependencies to fix this problem, but
I would suggest that you get rid of MakeAExp altogether.  Just give
(#+) and its friends the type "AExp s -> AExp s -> AExp s", with no
type-class constraint.  You need to explicitly inject FDVar into AExp,
but most of the time you probably just need to handle AExp values
without caring that they are constructed with Variable.  You also need
to inject Int into AExp, unless you simply make "instance Num (AExp s)".

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
Lemonade was a popular drink and it still is.

_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to