У меня есть следующий код:
{-# LANGUAGE DefaultSignatures#-}
import Control.Monad.Trans.Class
import Control.Monad.Trans.Maybe
class Monad m => MonadMaybe m where
liftMaybe :: Maybe a -> m a
default liftMaybe :: (MonadTrans t, MonadMaybe m) => Maybe a -> t m a
liftMaybe = lift . liftMaybe
instance MonadMaybe m => MonadMaybe (MaybeT m)
Используя систему компиляции Glorious Glasgow Haskell, версия 8.0.1.20161117, это не скомпилируется:
foo.hs:11:10: error:
• Couldn't match type ‘m’ with ‘MaybeT m’
‘m’ is a rigid type variable bound by
the instance declaration at foo.hs:11:10
Expected type: Maybe a -> MaybeT m a
Actual type: Maybe a -> MaybeT (MaybeT m) a
• In the expression: Main.$dmliftMaybe @MaybeT m
In an equation for ‘liftMaybe’:
liftMaybe = Main.$dmliftMaybe @MaybeT m
In the instance declaration for ‘MonadMaybe (MaybeT m)’
• Relevant bindings include
liftMaybe :: Maybe a -> MaybeT m a (bound at foo.hs:11:10)
Однако в GHC 7.10 это компилируется без проблем.
Правильно ли GHC 8, или я нашел ошибку?