diff options
Diffstat (limited to 'testsuite/tests/deriving/should_compile/drv020.hs')
-rw-r--r-- | testsuite/tests/deriving/should_compile/drv020.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/testsuite/tests/deriving/should_compile/drv020.hs b/testsuite/tests/deriving/should_compile/drv020.hs index 8794b745e5..9956407fbd 100644 --- a/testsuite/tests/deriving/should_compile/drv020.hs +++ b/testsuite/tests/deriving/should_compile/drv020.hs @@ -5,6 +5,9 @@ -- one-argument newtype defined in the same module module ShouldSucceed where +import Control.Applicative (Applicative(..)) +import Control.Monad (liftM, ap) + -- library stuff class Monad m => MonadState s m | m -> s where @@ -15,6 +18,13 @@ newtype State s a = State { runState :: (s -> (a, s)) } +instance Functor (State s) where + fmap = liftM + +instance Applicative (State s) where + pure = return + (<*>) = ap + instance Monad (State s) where return a = State $ \s -> (a, s) m >>= k = State $ \s -> let @@ -28,7 +38,7 @@ instance MonadState s (State s) where -- test code newtype Foo a = MkFoo (State Int a) - deriving (Monad, MonadState Int) + deriving (Functor, Applicative, Monad, MonadState Int) f :: Foo Int f = get |