Test Trac #11552
[ghc.git] / testsuite / tests / typecheck / should_compile / T11552.hs
1 {-# LANGUAGE InstanceSigs #-}
2 {-# LANGUAGE ScopedTypeVariables #-}
3
4 module T11552 where
5
6 newtype MaybeT m a =
7 MaybeT { runMaybeT :: m (Maybe a) }
8
9 instance (Functor m) => Functor (MaybeT m) where
10 fmap f (MaybeT ma) =
11 MaybeT $ (fmap . fmap) f ma
12
13 instance forall f . (Applicative f) => Applicative (MaybeT f) where
14 pure :: a -> MaybeT f a
15 pure x = MaybeT (pure (pure x))
16
17 (<*>) :: forall a b . Applicative f => MaybeT f (a -> b) -> MaybeT f a -> MaybeT f b
18 (MaybeT fab) <*> (MaybeT mma) =
19 let fab' :: f (Maybe (a -> b))
20 fab' = fab
21 in MaybeT $ undefined