Commit d53022ae authored by bjorn@bringert.net's avatar bjorn@bringert.net
Browse files

Added drv020, a test for newtype deriving of multi-parameter type classes...

Added drv020, a test for newtype deriving of multi-parameter type classes which currently makes HEAD panic.
It is called drv020 in order not to clash with some yet to be pushed test cases for stand-alone deriving.
parent 10af7cf9
......@@ -10,3 +10,4 @@ test('drv009', normal, compile, [''])
test('drv010', normal, compile, [''])
test('drv011', normal, compile, [''])
test('drv012', normal, compile, [''])
test('drv020', normal, compile, [''])
{-# OPTIONS_GHC -fglasgow-exts #-}
-- Test deriving of a multi-parameter class for
-- one-argument newtype defined in the same module
module ShouldSucceed where
-- library stuff
class Monad m => MonadState s m | m -> s where
get :: m s
put :: s -> m ()
newtype State s a = State {
runState :: (s -> (a, s))
}
instance Monad (State s) where
return a = State $ \s -> (a, s)
m >>= k = State $ \s -> let
(a, s') = runState m s
in runState (k a) s'
instance MonadState s (State s) where
get = State $ \s -> (s, s)
put s = State $ \_ -> ((), s)
-- test code
newtype Foo a = MkFoo (State Int a)
deriving (Monad, MonadState Int)
f :: Foo Int
f = get
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