我已经在这里问过这个问题,但我想我也会尝试。
如何添加MonadLogger
到这个免费的单子变压器堆栈?
newtype Craft a = Craft { unCraft :: ReaderT CraftEnv (FreeT CraftDSL IO) a }
deriving ( Functor, Monad, MonadIO, Applicative
, MonadReader CraftEnv, MonadFree CraftDSL, MonadThrow)
我可以MonadThrow
毫无问题地添加;我希望添加MonadLogger
会同样容易。
我尝试添加它并收到此错误:
No instance for (MonadLogger (FreeT CraftDSL IO))
arising from the 'deriving' clause of a data type declaration
如果我定义一个实例:
instance MonadLogger (FreeT CraftDSL IO) where
monadLoggerLog a b c d = Trans.lift $ monadLoggerLog a b c d
我收到此错误:
Could not deduce (MonadLogger IO)
arising from a use of ‘monadLoggerLog’
这是我正在编译的基本示例的链接。