Proposal: add replay function to Control.Monad.Cont.Class
Zemyla
zemyla at gmail.com
Sun Mar 7 18:35:21 UTC 2021
I kind of don't like it, because the continuation doesn't return anything
but itself. I'd prefer something that works more like the setjmp function
in C, taking a value and returning the value plus a function that lets it
return the new value:
setJump :: MonadCont m => a -> m (a -> m b, a)
setJump a = callCC $ \k -> let
go b = k (go, b)
in pure (go, a)
On Sun, Mar 7, 2021, 11:36 Carter Schonwald <carter.schonwald at gmail.com>
wrote:
> Yeah
>
> On Sun, Mar 7, 2021 at 12:16 PM Edward Kmett <ekmett at gmail.com> wrote:
>
>> I rather like label. +1 from me.
>>
>> On Sun, Mar 7, 2021 at 1:25 AM Tom Ellis <
>> tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk> wrote:
>>
>>> On Sun, Mar 07, 2021 at 03:25:16AM +0000, Alexandre Esteves wrote:
>>> > replay :: MonadCont m => m (m a)
>>> > replay = callCC $ pure . fix
>>> >
>>> > Using this in a do-notation block allows one to bind a name to the
>>> > sub-block that starts immediately after.
>>> > I reached for continuations to try to get this behavior for use with
>>> > recursive flows without disrupting the reading of the main forward
>>> flow and
>>> > found how to do it in https://jsdw.me/posts/haskell-cont-monad/ under
>>> the
>>> > name "goto".
>>> >
>>> > While "goto" is as familiar as a name can be, I feel "replay" more
>>> > accurately conveys, that you can only 'go back', by stating what
>>> actually
>>> > is happening - that a sub-block we're currently evaluating is replayed
>>> from
>>> > its beginning.
>>>
>>> Looks like a "label" more than a "goto" to me. Would "label" be a
>>> good name?
>>> _______________________________________________
>>> Libraries mailing list
>>> Libraries at haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20210307/539f6d27/attachment.html>
More information about the Libraries
mailing list