From b3c6ee0e0185f45d6a9092b5c1f84120c3b8d16d Mon Sep 17 00:00:00 2001 From: simonpj Date: Mon, 8 Jun 1998 10:41:09 +0000 Subject: [PATCH] [project @ 1998-06-08 10:41:08 by simonpj] --- ghc/tests/typecheck/should_compile/tc098.hs | 31 +++++++++++++++++++++++ ghc/tests/typecheck/should_compile/tc098.stderr | 8 ++++++ 2 files changed, 39 insertions(+) create mode 100644 ghc/tests/typecheck/should_compile/tc098.hs create mode 100644 ghc/tests/typecheck/should_compile/tc098.stderr diff --git a/ghc/tests/typecheck/should_compile/tc098.hs b/ghc/tests/typecheck/should_compile/tc098.hs new file mode 100644 index 0000000..5fc404b --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc098.hs @@ -0,0 +1,31 @@ +--!!! Ambiguity in local declarations + +module ShouldSucceed where + +type Cp a = a -> a -> Ordering + +m :: Eq a => Cp a -> [a] -> a +m _ [x,y,z] = if x==y then x else z + +cpPairs :: Cp [j] -> (a,[j]) -> (a,[j]) -> Ordering +cpPairs cp (_,p) (_,q) = cp p q + +mp :: (Eq i,Eq j) => Cp [j] -> [(i,[j])] -> (i,[j]) +mp cp dD = + let minInRow = m (cpPairs cp) + in minInRow dD + +{- GHC 3.02 reported + + T.hs:24: + Ambiguous type variable(s) + `j' in the constraint `Eq (aYD, [j])' + arising from use of `m' at T.hs:24 + In an equation for function `mp': + mp cp dD = let minInRow = m (cpPairs cp) in minInRow dD + +This was because the ambiguity test in tcSimplify didn't +take account of the type variables free in the environment. + +It should compile fine. +-} diff --git a/ghc/tests/typecheck/should_compile/tc098.stderr b/ghc/tests/typecheck/should_compile/tc098.stderr new file mode 100644 index 0000000..1081509 --- /dev/null +++ b/ghc/tests/typecheck/should_compile/tc098.stderr @@ -0,0 +1,8 @@ +ghc: module version changed to 1; reason: no old .hi file +_exports_ +ShouldSucceed cpPairs m mp Cp; +_declarations_ +1 cpPairs _:_ _forall_ [a b] => Cp [a] -> (b, [a]) -> (b, [a]) -> PrelBase.Ordering ;; +1 m _:_ _forall_ [a] {PrelBase.Eq a} => Cp a -> [a] -> a ;; +1 mp _:_ _forall_ [a b] {PrelBase.Eq b, PrelBase.Eq a} => Cp [a] -> [(b, [a])] -> (b, [a]) ;; +1 type Cp a = a -> a -> PrelBase.Ordering ; -- 1.7.10.4