Haskell 可以推导出MonadState s
inT1
下面的实例,但不是 in T2
which 是非常相似的类型。我应该以哪种方式修改代码T2
以便MonadState s
可以自动派生实例?
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.Reader
import Control.Monad.State
newtype T1 r s a =
T1 { runT1 :: ReaderT r (State s) a }
deriving (Monad, MonadReader r, MonadState s)
newtype T2 r s a =
T2 { runT2 :: StateT r (State s) a }
deriving (Monad, MonadState r, MonadState s)