我的印象是,每个类型的值a
都可以用newtype Id a = Id {runId :: forall r. (a -> r) -> r }
连续传递风格的 2 级多态类型来描述。所以我派生了以下类型来Reader
相应地定义:
newtype Reader e a = Reader {runReader :: forall r. ((e -> a) -> r) -> r}
然后我尝试构造一个这种类型的值并运行它:
reader f = Reader (\k -> k f) -- where is f's argument?
runReader (reader id) -- what is the 2nd argument?
如果Reader
CPS 中的编码及其类型有效,我将如何使用它?