summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/tc229.hs
blob: 406edf60a315f52f725af4e171fa3121bec5abb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{-# OPTIONS_GHC -Wno-redundant-constraints -Wno-simplifiable-class-constraints #-}

-- trac #1406: Constraint doesn't reduce in the presence of quantified
--             type variables

{-# LANGUAGE FlexibleInstances, UndecidableInstances, RankNTypes, FlexibleContexts,
             MultiParamTypeClasses, FunctionalDependencies #-}

module Problem where

data Z
data S a

class HPrefix l
instance (NSub (S Z) ndiff, HDrop ndiff l l) => HPrefix l
-- Weird test case: (NSub (S Z) ndiff) is simplifiable

class NSub n1 n3 | n1 -> n3
instance NSub Z Z
instance NSub n1 n3 => NSub (S n1) n3

class HDrop n l1 l2 | n l1 -> l2
instance HDrop Z l l

t_hPrefix :: HPrefix l => l -> ()
-- Weird test case: (HPrefix l) is simplifiable
t_hPrefix = undefined

-- In ghc 6.6.1 this works...
thr' :: (forall r. l -> a) -> a
thr' f = f undefined
thP4' = thr' t_hPrefix

-- ... but this doesn't work...?
thr :: (forall r. r -> a) -> a
thr f = f undefined
thP4 = thr t_hPrefix