[Haskell-beginners] Continuations vs. Values

John Wiegley johnw at newartisans.com
Sun Sep 7 12:57:09 UTC 2014


>>>>> martin  <martin.drautzburg at web.de> writes:

> Can someone help me cross this gap? There must be certain things I can do
> with Conts which I cannot do easily with values and functions.

Any function can be turned into a function accepting a continuation:

         f :: a -> b

    f_cont :: a -> (b -> c) -> c

The Cont construction abstracts this pattern into its own type:

    f_Cont :: a -> Cont c b

The advantage is that we now have a Functor instance over 'b', rather than
over 'c' (for Functor (->) applied to f_cont).

I cover Cont is more detail here, with a reference to green threading at the
very bottom:

    https://www.fpcomplete.com/user/jwiegley/understanding-continuations

John


More information about the Beginners mailing list