Bump `base` version to 4.9.0.0 (closes #11026)
[ghc.git] / testsuite / tests / typecheck / should_fail / tcfail093.hs
1 {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies,
2 FlexibleInstances, UndecidableInstances, FlexibleContexts #-}
3 -- UndecidableInstances now needed because the Coverage Condition fails
4
5 module ShouldFail where
6
7 -- A stripped down functional-dependency
8 -- example that causes GHC 4.08.1 to crash with:
9 -- "basicTypes/Var.lhs:194: Non-exhaustive patterns in function readMutTyVar"
10 -- Reported by Thomas Hallgren Nov 00
11
12 -- July 07: I'm changing this from "should fail" to "should succeed"
13 -- See Note [Important subtlety in oclose] in FunDeps
14
15
16 primDup :: Int -> IO Int
17 primDup = undefined
18
19 dup () = call primDup
20
21 -- call :: Call c h => c -> h
22 --
23 -- call primDup :: {Call (Int -> IO Int) h} => h with
24 -- Using the instance decl gives
25 -- call primDup :: {Call (IO Int) h'} => Int -> h'
26 -- The functional dependency means that h must be constant
27 -- Hence program is rejected because it can't find an instance
28 -- for {Call (IO Int) h'}
29
30 class Call c h | c -> h where
31 call :: c -> h
32
33 instance Call c h => Call (Int->c) (Int->h) where
34 call f = call . f
35
36