The following module is rejected by both
ghc -fglasgow-exts -fallow-undecidable-instances
and
hugs -98
------------------------------------------------------------------------
class HasFoo a foo | a -> foo where
foo :: a -> foo
data A = A Int
data B = B A
instance HasFoo A Int where
foo (A x) = x
instance HasFoo A foo => HasFoo B foo where
foo (B a) = foo a
------------------------------------------------------------------------
The error messsage says that the type inferred for foo in B's instance
is not general enough: the rhs has type "HasFoo B Int => B -> Int", but
"HasFoo B foo => B -> foo" was expected.
Should it really be wrong? I don't know the details of type inference
with fundeps, but intuitively it should work, yielding an instance
HasFoo B Int. Could it be made legal please?
With the fundep removed, it works.
I need it for a preprocessor which generates instances like that for B
without knowing the type to put as the second class argument. Fundeps
aren't essential, but...
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell