ScopedTypeVariables / InstanceSigs do not work in GHC 8.0
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE ScopedTypeVariables #-}
module MyMaybeT where
newtype MaybeT m a =
MaybeT { runMaybeT :: m (Maybe a) }
instance (Functor m) => Functor (MaybeT m) where
fmap f (MaybeT ma) =
MaybeT $ (fmap . fmap) f ma
instance forall f . (Applicative f) => Applicative (MaybeT f) where
pure :: a -> MaybeT f a
pure x = MaybeT (pure (pure x))
(<*>) :: forall a b . Applicative f => MaybeT f (a -> b) -> MaybeT f a -> MaybeT f b
(MaybeT fab) <*> (MaybeT mma) =
let fab' :: f (Maybe (a -> b))
fab' = fab
in MaybeT $ undefined
Works fine in 7.10.3, breaks in GHC 8.0:
Prelude> :l code/myMaybeT1.hs
[1 of 1] Compiling MyMaybeT ( code/myMaybeT1.hs, interpreted )
code/myMaybeT1.hs:13:10: error:
Malformed instance: forall f.
(Applicative f) => Applicative (MaybeT f)
code/myMaybeT1.hs:14:3: error:
The class method signature for ‘pure’ lacks an accompanying binding
(The class method signature must be given where ‘pure’ is declared)
code/myMaybeT1.hs:17:3: error:
The class method signature for ‘<*>’ lacks an accompanying binding
(The class method signature must be given where ‘<*>’ is declared)
code/myMaybeT1.hs:17:37: error: Not in scope: type variable ‘f’
code/myMaybeT1.hs:17:49: error: Not in scope: type variable ‘f’
code/myMaybeT1.hs:17:70: error: Not in scope: type variable ‘f’
code/myMaybeT1.hs:17:84: error: Not in scope: type variable ‘f’
Failed, modules loaded: none.
$ ghci --version
The Glorious Glasgow Haskell Compilation System, version 8.0.0.20160122