Commit 4ff86af8 authored by simonpj's avatar simonpj
Browse files

[project @ 2005-05-24 10:44:50 by simonpj]

Add a fundep test
parent 12591c5e
......@@ -122,3 +122,4 @@ test('tcfail134', normal, compile_fail, [''])
test('tcfail135', normal, compile_fail, [''])
test('tcfail136', normal, compile_fail, [''])
test('tcfail137', normal, compile_fail, [''])
test('tcfail138', normal, compile_fail, [''])
{-# OPTIONS -fglasgow-exts #-}
-- This one shows up another rather subtle functional-dependecy
-- case. The error is:
--
-- Could not deduce (C a b') from the context (C a b)
-- arising from the superclasses of an instance declaration at Foo.hs:8:0
-- Probable fix: add (C a b') to the instance declaration superclass context
-- In the instance declaration for `C (Maybe a) a'
--
-- Since L is a superclass of the (sought) constraint (C a b'), you might
-- think that we'd generate the superclasses (L a b') and (L a b), and now
-- the fundep will force b=b'. But GHC is very cautious about generating
-- superclasses when doing context reduction for instance declarations,
-- becasue of the danger of superclass loops.
--
-- So, today, this program fails. It's trivial to fix by adding a fundep for C
-- class (G a, L a b) => C a b | a -> b
module ShouldFail where
class G a
class L a b | a -> b
class (G a, L a b) => C a b
instance C a b' => G (Maybe a)
instance C a b => C (Maybe a) a
instance L (Maybe a) a
tcfail138.hs:27:0:
Could not deduce (C a b') from the context (C a b)
arising from the superclasses of an instance declaration at tcfail138.hs:27:0
Probable fix: add (C a b') to the instance declaration superclass context
In the instance declaration for `C (Maybe a) a'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment