I was under the impression that every value of type a
can be described with a rank-2 polymorphic type newtype Id a = Id {runId :: forall r. (a -> r) -> r }
in continuation passing style. So I derived the following type to define the Reader
accordingly:
newtype Reader e a = Reader {runReader :: forall r. ((e -> a) -> r) -> r}
Then I tried to construct a value of this type and run it:
reader f = Reader (\k -> k f) -- where is f's argument?
runReader (reader id) -- what is the 2nd argument?
Provided that Reader
's encoding in CPS and its type are valid, how would I use it?