Skip to content

Instantly share code, notes, and snippets.

View ymdfield's full-sized avatar

Riyo ymdfield

  • Tokyo, Japan
  • 06:33 (UTC +09:00)
  • X @ymdfield
View GitHub Profile
@kory33
kory33 / response.md
Created February 3, 2026 21:45
20260204 rizkubo さんへの返信

https://x.com/rizkubo/status/2013122492244611503

↑ のポストへの返信を、読みやすいようにマークアップしたものです。

本文

こちらも妥当な質問だと思います。まず主張をもう少し明確にさせてください。

まず、「for/doは[...]脱糖してるだけ」はその通りです。しかし、「プログラムの実行をある程度許して」というのは、for/doプログラムの実行をする、と言いたかったのではなく、「自由でない >>= 演算が、一般に、なんらかの意味で部分的にプログラムを実行しており」「そういう、プログラムを部分的に実行するような >>= 演算についても合成を書きやすくするのが for/do という構文だ」「だから、for/do はそういう意味で .replaceExits の一般化になっている」という立場があり得るというのが僕の主張でした。

@marcinzh
marcinzh / CatchFail.scala
Created May 28, 2025 13:38
CatchFail.hs translated to Scala 3 and Turbolift
//> using scala "3.3.5"
//> using dep "io.github.marcinzh::turbolift-core:0.112.0"
//> using dep "io.github.marcinzh::turbolift-bindless:0.112.0"
/*********************************************************************************************
How to run:
1. Ensure you have Java 11 or newer
2. Install scala-cli
3. Execute `scala-cli <link-to-this-gist>`
Link to the original:

Monads and delimited control are very closely related, so it isn’t too hard to understand them in terms of one another. From a monadic point of view, the big idea is that if you have the computation m >>= f, then f is m’s continuation. It’s the function that is called with m’s result to continue execution after m returns.

If you have a long chain of binds, the continuation is just the composition of all of them. So, for example, if you have

m >>= f >>= g >>= h

then the continuation of m is f >=> g >=> h. Likewise, the continuation of m >>= f is g >=> h.