Commit d859bd8d authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Add test for Trac #3621

parent d6cd3f27
{-# LANGUAGE GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies #-}
module T3621 where
-- This one is ok, even though the deriving clause mentions 'a'
-- which is not a parameter of 'T'
class C a b
instance C a S
data S = MkS
newtype T = MkT S deriving( C a )
-- But this one fails, and should fail
class (Monad m) => MonadState s m | m -> s where
newtype State s a = State { runState :: s -> (a, s) }
instance Monad (State s) where {}
instance MonadState s (State s) where {}
newtype WrappedState s a = WS { runWS :: State s a }
deriving (Monad, MonadState state)
Couldn't match expected type `state' against inferred type `s'
`state' is a rigid type variable bound by
the instance declaration at T3621.hs:21:32
`s' is a rigid type variable bound by
the instance declaration at T3621.hs:20:21
When using functional dependencies to combine
MonadState s (State s),
arising from the dependency `m -> s'
in the instance declaration at T3621.hs:18:9
MonadState state (State s),
arising from the instance declaration at T3621.hs:21:21-36
When checking the super-classes of an instance declaration
In the instance declaration for `MonadState state (WrappedState s)'
......@@ -24,6 +24,7 @@ test('T2701', normal, compile_fail, [''])
test('T2851', normal, compile_fail, [''])
test('T2721', normal, compile_fail, [''])
test('T3101', normal, compile_fail, [''])
test('T3621', normal, compile_fail, [''])
if_compiler_lt('ghc', '6.11', expect_fail),
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