-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Continuation monads #700
Comments
I'd like to see this |
This blog post makes a better argument for value of continuation monads than I would have made: |
I took a stab at this: I don't see how to make it totally stack safe. I had an idea to use threads but that seems terrible. Anyway, something like my above implementation may actually be useful because stack depth is only proportional to the number of nested continuations, not flatMaps (which are trampolined). I played with using this for the poor man's concurrency monad, and it seems okay. I (or anyone) could make a cats PR if we think this would be generally useful. |
@johnynek that looks very cool! To the extent that I understand the use cases I've seen (which isn't as much as I'd like), I don't think they would manifest deep stacks. |
Would get a 👍 from me. It would also give me an opportunity to harp on about extensible effects and |
take a look at the PR: #1400 |
For all, who needs continuation monad, I just ported IndexedContT from scalaz: https://github.com/danslapman/cats-conts |
Very cool. Reading Bartosz Milewski's Category Theory for Programmers, Scala edition I understood that continuations are essentially what the Yoneda Lemma is about. So I also looked around to get a better grip on how these tie in to practical applications. In a way it's not difficult - there are many examples of CPS in JS, etc... The tricky bit is getting to the point that it is crystal clear how the theory and practice tie together, so that one can explain it and think with it in everyday coding. Many of the blog posts on the topic are in Haskell. The best of them was the continuation monad post referenced by @erikerlandson above. There is also The mother of all monads which I thought very helpful. There is the nice tutorials in Scala on continuations by @DevInsideYou (to get the full picture one should watch the previous and the next one). But from that I got the impression that the problem with continuations is that they don't really work that well in Scala because of the danger of them using up the whole stack. But I see that the second PR on this topic makes them stack safe! DevInsideYou then moves over to the There is video on using continuations to build web services in Scala. |
FYI this might be helpful to learning too:
https://github.com/japgolly/scalajs-react/blob/master/core/src/main/scala/japgolly/scalajs/react/AsyncCallback.scala
It's ContT IO specialised for JS (where you read CallbackTo it's
effectively IO). It allows people to write async code in scalajs-react in a
manner similar to how people use Future, and purely.
…On Thu, 22 Aug. 2019, 7:23 pm Henry Story, ***@***.***> wrote:
Very cool. Reading Bartosz Milewski's Category Theory for Programmers,
Scala edition <https://twitter.com/hmemcpy/status/1160870623943561216> I
understood that continuations are essentially what the Yoneda Lemma is
about. So I also looked around to get a better grip on how these tie in to
practical applications. In a way it's not difficult - there are many
examples of CPS in JS, etc... The tricky bit is getting to the point that
it is crystal clear how the theory and practice tie together, so that one
can explain it and think with it in everyday coding.
Many of the blog posts on the topic are in Haskell. The best of them was
the continuation monad
<http://www.haskellforall.com/2012/12/the-continuation-monad.html> post
referenced by @erikerlandson <https://github.com/erikerlandson> above.
There is also The mother of all monads
<http://blog.sigfpe.com/2008/12/mother-of-all-monads.html> which I
thought very helpful.
There is a whole list of examples on the Reddit discussion thread: Real
world examples of the Cont Monad
<https://www.reddit.com/r/haskell/comments/38zpuo/real_world_examples_of_the_cont_monad/>.
Looking through that I found a video lecture in Haskell Continuation
Passing Style in Haskell
<https://begriffs.com/posts/2015-06-03-haskell-continuations.html>. There
was a blog post that showed in Haskell how to build web pages, but it had
functions that were so long that it really was incomprehensible.
There is the nice turtorials in Scala on continuations
<https://www.youtube.com/watch?v=93NZXOGG8ak> by @DevInsideYou
<https://github.com/DevInsideYou> (to get the full picture one should
watch the previous and the next one). But from that I got the impression
that the problem with continuations is that they don't really work that
well in Scala because of the danger of them using up the whole stack. But I
see that the second PR on this topic
<#2506 (comment)>
makes them stack safe! DevInsideYou then moves over to the
Cont class in Scala to help with recursive datatypes and then moves on to
FreeMonads. So I ended up getting the impression that there is a relation
between Cont and Free Monads. So I found this article that Continuation
passing style Free Monads and direct style Free Monads
<https://deque.blog/2017/12/08/continuation-passing-style-free-monads-and-direct-style-free-monads/>
There is video on using continuations to build web services
<http://cufp.org/2016/building-a-web-application-with-continuation-monads.html>
in Scala.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#700?email_source=notifications&email_token=AABRRN32GRNOZMICXFMOBT3QFZLJVA5CNFSM4BVC6DXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD44O64Q#issuecomment-523825010>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABRRN6JZV5JHUM36EGZLQTQFZLJVANCNFSM4BVC6DXA>
.
|
Good afternoon! So, looking at the current If there is a desire to add the |
Yeah I forgot to link to this from #2506 Indexed has not been done that I know of. |
Should
Cont
,ContT
,IndexedContT
be added to cats? What would be the proper place to add them?The text was updated successfully, but these errors were encountered: