Commit d79c57bb authored by simonpj's avatar simonpj
Browse files

[project @ 2001-02-20 08:57:46 by simonpj]

Add fundeps tests
parent d9ab3ccf
{-# OPTIONS -fglasgow-exts #-}
-- !!! Functional dependencies
-- This broke an early impl of functional dependencies
-- (complaint about ambiguity)
module ShouldCompile where
class C a b | a -> b where f :: a -> b
g :: (C a b, Eq b) => a -> Bool
g x = f x == f x
-- !!! Monomorphism restriction
module ShouldCompile
foo :: Eq a => a -> b -> b
foo x y = y
-- Expect test2 :: forall b. b->b
-- despite the monomorphism restriction
poly = foo (3::Int)
-- Check that test2 is polymorphic
test = (poly True, poly 'c')
{-# OPTIONS -fglasgow-exts #-}
-- !!! Functional dependencies
-- This broke an early impl of functional dependencies
module ShouldCompile where
class Foo r a | r -> a where
foo :: a -> r
instance Foo (Maybe e) e where
foo = Just
bad:: Num e => Maybe e
bad = foo 0
{-# OPTIONS -fglasgow-exts #-}
-- !!! Functional dependencies
-- This broke an early impl of functional dependencies
-- (complaining about ambiguity)
module ShouldCompile where
class Foo r a | r -> a where
foo :: r -> a
instance Foo [m a] (m a)
bad:: Monad m => m a
bad = foo bar
bar:: Monad m => [m a]
bar = []
{-# OPTIONS -fglasgow-exts #-}
-- !!! Functional dependencies
-- This broke an early impl of functional dependencies
-- (caused a panic)
module ShouldCompile where
class Foo r a | r -> a where
foo :: r -> a
instance Foo [m a] (m a)
bad:: Monad m => m a
bad = foo bar
bar:: [m a]
bar = []
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