不像
MonadReader
和
MonadState
, the
MonadCont
类型类
takes only one parameter
.因为那个参数
m
必须是
Monad
,一定有种
* -> *
.
在派生子句中,
MonadCont,
不
MonadCont Pause
.
针对以下问题增加:
ContT
is defined as:
newtype ContT r m a = ContT { runContT :: (a -> m r) -> m r }
请注意
r
在你的定义中
newtype M r
作为决赛通过(
a
参数到
康特
. 插入变量,你有
ContT Bool (State StateType) a = ContT {
runContT :: (a -> State StateType Bool) -> (State StateType Bool)
}
这提供了一个计算上下文,您可以在其中操作
StateType
,并使用分隔的延续。最终,您将构造一个
ContT Bool (State StateType) Bool
. 然后可以运行继续(使用
evalContT
然后回到简单的
State StateType
语境。(实际上,您可以在程序的同一部分中打开所有3个Monad变压器。)