74ee993e948361e8ca7a70e2e862d60b382a65ba
[ghc-hetmet.git] / ghc / tests / typecheck / should_fail / tcfail093.hs
1 {-# OPTIONS -fglasgow-exts #-}
2
3 module ShouldFail where
4
5 -- A stripped down functional-dependency 
6 -- example that causes GHC 4.08.1 to crash with:
7 -- "basicTypes/Var.lhs:194: Non-exhaustive patterns in function readMutTyVar"
8 -- Reported by Thomas Hallgren Nov 00
9
10
11 primDup :: Int -> IO Int
12 primDup = undefined
13
14 dup () = call primDup
15
16 --      call :: Call c h => c -> h
17 --
18 --      call primDup :: {Call (Int -> IO Int) h} => h  with  
19 --  Using the instance decl gives
20 --      call primDup :: {Call (IO Int) h'} => Int -> h'
21 --  The functional dependency means that h must be constant
22 --  Hence program is rejected because it can't find an instance 
23 --  for {Call (IO Int) h'}
24
25 class Call    c h | c -> h where
26     call  :: c -> h
27
28 instance Call c h => Call (Int->c) (Int->h) where 
29     call f = call . f
30
31