Commit 253a91ce authored by simonpj's avatar simonpj
Browse files

[project @ 2004-04-02 13:29:20 by simonpj]

More tests
parent 5475292d
......@@ -185,3 +185,5 @@ test('tc174', normal, compile, [''])
test('tc175', normal, compile, [''])
test('tc176', normal, compile, [''])
test('tc177', normal, compile, [''])
test('tc178', normal, compile, [''])
test('tc179', normal, compile, [''])
-- See SourceForge bug 807249
-- Dies because the instance decl has type variables with
-- Gives a bogus type error
-- No instance for (Show (t -> Bool))
-- arising from use of `show' at tc175.hs:11:8-11
-- In the definition of `foo': foo x = show (\ _ -> True)
-- because the instance decl has type variables with
-- kind *, whereas the constraint (Show (x -> Bool)) has x::??
-- Kind of stupid, really, but awkward to fix.
......
{-# OPTIONS -fglasgow-exts #-}
-- This one tickled the kind-check in TcType.matchTys,
-- which should use sub-kinding
module ShouldCompile where
type TypeRep = ()
class Typeable2 t where
typeOf2 :: t a b -> TypeRep
class Typeable1 t where
typeOf1 :: t a -> TypeRep
class Typeable0 a where
typeOf0 :: a -> TypeRep
instance Typeable2 (->) where
typeOf2 = undefined
instance (Typeable2 t, Typeable0 a) => Typeable1 (t a) where
typeOf1 = undefined
instance (Typeable1 t, Typeable0 a) => Typeable0 (t a) where
typeOf0 = undefined
class Typeable0 a => Data0 a where
dataTypeOf0 :: a -> Bool
instance (Data0 a, Data0 b) => Data0 (a -> b) where
dataTypeOf0 = undefined
foo :: (Typeable0 a, Typeable0 b) => (a -> b) -> TypeRep
foo f = typeOf0 f
{-# OPTIONS -fglasgow-exts -fallow-overlapping-instances -fallow-undecidable-instances #-}
-- Tests context reduction for existentials
module TestWrappedNode where
class Foo a where { op :: a -> Int }
instance Foo a => Foo [a] where -- NB overlap
op (x:xs) = op x
instance Foo [Int] where -- NB overlap
op x = 1
data T = forall a. Foo a => MkT a
f :: T -> Int
f (MkT x) = op [x,x]
-- The op [x,x] means we need (Foo [a]). We used to
-- complain, saying that the choice of instance depended on
-- the instantiation of 'a'; but of course it isn't *going*
-- to be instantiated.
......@@ -106,3 +106,4 @@ test('tcfail117', normal, compile_fail, [''])
test('tcfail118', normal, compile_fail, [''])
test('tcfail119', normal, compile_fail, [''])
test('tcfail120', normal, compile_fail, ['-farrows'])
test('tcfail121', normal, compile_fail, [''])
{-# OPTIONS -fglasgow-exts -fallow-overlapping-instances #-}
module ShouldFail where
class Foo a where
op :: a -> a
instance Foo a => Foo [a]
instance Foo [Int]
foo :: Foo a => [a] -> [a]
foo x = op x
-- Correct instance depends on instantiation of 'a'
tcfail121.hs:12:8:
Overlapping instances for Foo [a]
arising from use of `op' at tcfail121.hs:12:8-9
Matching instances:
tcfail121.hs:8:0: instance (Foo a) => Foo [a]
tcfail121.hs:9:0: instance Foo [Int]
(The choice depends on the instantiation of `a'
Use -fallow-incoherent-instances to use the first choice above)
In the definition of `foo': foo x = op x
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