Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Continuations vs. Values (martin)
   2. Re:  Continuations vs. Values (John Wiegley)


----------------------------------------------------------------------

Message: 1
Date: Sun, 07 Sep 2014 14:14:22 +0200
From: martin <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Continuations vs. Values
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-15

Hello all,

in the continuation monad, I can turn a value into a Cont by means of return. 
Conversely I can convert a Cont into a
value by passing id as the continuation. This dualism of Cont and plain values 
is well known.

The bind operator kind of(!) takes a value a and produces a new value b. This 
is all wrapped in Cont stuff, so the
result of bind is not really a plain a, but a Cont which takes a function from 
b -> r. But this is just the same dualism
as above.

Most Cont examples I've seen could much more easily be implemented with just 
values or calling functions on values. Then
again there is "a poor man's concurrency" which I don't get at all. In between 
there is a huge gap of (my) understanding.

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.


------------------------------

Message: 2
Date: Sun, 07 Sep 2014 14:57:09 +0200
From: "John Wiegley" <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Continuations vs. Values
Message-ID: <[email protected]>
Content-Type: text/plain

>>>>> martin  <[email protected]> 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


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 75, Issue 5
****************************************

Reply via email to