--- /dev/null
+{-# 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
--- /dev/null
+-- !!! 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')
--- /dev/null
+{-# 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
--- /dev/null
+{-# 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 = []
--- /dev/null
+{-# 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 = []