<div dir="ltr"><div>Agreed that 'label' is a better name than goto/replay.</div>It didn't even hit me until I saw setJump that `m (m a)` doesn't allow representing recursive functions with arguments, so `a -> m(a -> m b, a)` does seem much more expressive to me<div>Starting with my original examples, introducing the recursive binding when there are arguments would look like</div><div><br></div><div>`(numberPromptStep, (x,y)) <- setJump (x0, y0)`</div><div>`fix $ \numberPromptStep x y -> do`<br></div><div>`numberPromptStep x y = do`</div><div><br></div><div>It is slightly annoying that the later 2 can simply add an argument while setJump requires using the uncurried version but I don't see a way around that since >>= itself works that way</div><div>`m (m a)` is essentially the 0-tuple version of `a -> m(a -> m b, a)` which makes me wonder if it's even worth having. Sure, it's convenient not to have these unit/() around, but maybe the same argument (heh) could be made for 2-argument and 3-argument versions.</div><div><br></div><div>do<br></div><div><div> numberPromptStep <- setJump</div><div> (..)</div><div> numberPromptStep <br></div><div></div></div><div>do</div><div> (numberPromptStep, x, y) <- setJump2 x0 y0</div><div> (..)<br></div><div> numberPromptStep x' y'<br></div><div><br></div><div>Given that, I think `a -> m (a -> m b, a)` is the important one be it called label or setJump and maybe there can be a specialized 0-tuple version (e.g. label_ / setJump_) offering the `m (m a)` special case. I don't feel strongly about it though, since unlike `for_` it wouldn't actually relax constraints, only have a simpler signature.</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 7, 2021 at 7:33 PM David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Why not both?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 7, 2021, 1:36 PM Zemyla <<a href="mailto:zemyla@gmail.com" target="_blank">zemyla@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">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:<div dir="auto"><br></div><div dir="auto">setJump :: MonadCont m => a -> m (a -> m b, a)</div><div dir="auto">setJump a = callCC $ \k -> let</div><div dir="auto"> go b = k (go, b)</div><div dir="auto"> in pure (go, a)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 7, 2021, 11:36 Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com" rel="noreferrer" target="_blank">carter.schonwald@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Yeah </div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 7, 2021 at 12:16 PM Edward Kmett <<a href="mailto:ekmett@gmail.com" rel="noreferrer noreferrer" target="_blank">ekmett@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I rather like label. +1 from me.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 7, 2021 at 1:25 AM Tom Ellis <<a href="mailto:tom-lists-haskell-cafe-2017@jaguarpaw.co.uk" rel="noreferrer noreferrer" target="_blank">tom-lists-haskell-cafe-2017@jaguarpaw.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sun, Mar 07, 2021 at 03:25:16AM +0000, Alexandre Esteves wrote:<br>
> replay :: MonadCont m => m (m a)<br>
> replay = callCC $ pure . fix<br>
> <br>
> Using this in a do-notation block allows one to bind a name to the<br>
> sub-block that starts immediately after.<br>
> I reached for continuations to try to get this behavior for use with<br>
> recursive flows without disrupting the reading of the main forward flow and<br>
> found how to do it in <a href="https://jsdw.me/posts/haskell-cont-monad/" rel="noreferrer noreferrer noreferrer" target="_blank">https://jsdw.me/posts/haskell-cont-monad/</a> under the<br>
> name "goto".<br>
> <br>
> While "goto" is as familiar as a name can be, I feel "replay" more<br>
> accurately conveys, that you can only 'go back', by stating what actually<br>
> is happening - that a sub-block we're currently evaluating is replayed from<br>
> its beginning.<br>
<br>
Looks like a "label" more than a "goto" to me. Would "label" be a<br>
good name?<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" rel="noreferrer noreferrer" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" rel="noreferrer noreferrer" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div></div>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" rel="noreferrer noreferrer" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" rel="noreferrer" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>