Stream: compiler development

Topic: Cor experiment for effect interpreters and inference


view this post on Zulip Ayaz Hafiz (Nov 24 2023 at 23:00):

I made a new cor experiment to figure out if I could make a simpler model for effect interpreters to work, and to explore some of the inference changes mentioned in https://roc.zulipchat.com/#narrow/stream/395097-compiler-development/topic/Allowing.20implicit.20cycles.20in.20the.20type.20representation

view this post on Zulip Ayaz Hafiz (Nov 24 2023 at 23:00):

Here's the compiler

view this post on Zulip Ayaz Hafiz (Nov 24 2023 at 23:01):

The good news: I got https://github.com/roc-lang/roc/issues/5464 working with an effect interpreter model without lambda sets (see this playground). The IR is kind of insane though, 2K lines of IR for 50 lines of code (admittedly it's sparse)

view this post on Zulip Ayaz Hafiz (Nov 24 2023 at 23:02):

Also, composable effect interpreters work

view this post on Zulip Ayaz Hafiz (Nov 24 2023 at 23:03):

Also for some reason the inference/propagation of type aliases is really nice (hover over some variables here to see)

view this post on Zulip Ayaz Hafiz (Nov 24 2023 at 23:04):

The next step is to see if this can work with lambda sets, and if so, we should probably translate the new algorithms in-place to the compiler. If anyone wants to play around with this and/or hack on it with your own experiments, let me know. The source is https://github.com/ayazhafiz/cor/tree/base/experiments/compose_fx

view this post on Zulip Richard Feldman (Nov 25 2023 at 00:08):

this is super exciting! :smiley:

does it already do the "record captures in canonicalization for type annotations" thing that turned out to be necessary for lambda set correctness in annotations?

view this post on Zulip Ayaz Hafiz (Nov 25 2023 at 00:44):

no, neither mutual recursion nor lambda sets are around

view this post on Zulip Ayaz Hafiz (Dec 10 2023 at 03:30):

For anyone interested, I've still been working on this sometimes in my free time (current playground). I'm having some trouble getting lambda sets working across the board, but you'll see that most examples work (except the #5464 reproducer examples).

view this post on Zulip Ayaz Hafiz (Dec 10 2023 at 03:31):

The positive news is I think the idea of going full in to equirecursive types and not trying to track "recursion pointers" in the frontend IR (i.e. before the equivalent of Roc's mono IR) is definitely the way to go

view this post on Zulip Ayaz Hafiz (Dec 10 2023 at 03:33):

And, I think I've found a much easier method for specializing on types than we currently use (@Folkert de Vries recently talked about the annoyance of having to specialize on a per-symbol basis in the current Roc implementation, which seems unnecessary). Obviously this project is only a subset of Roc, but the monomorphizer and IR generator are each like 400 LoC even with lambda sets

view this post on Zulip Richard Feldman (Dec 10 2023 at 04:30):

I am SO, SO HYPE about this!!!

view this post on Zulip Richard Feldman (Dec 10 2023 at 04:30):

how are you feeling about the lambda set issues?

view this post on Zulip Richard Feldman (Dec 10 2023 at 04:31):

tractable but tricky? Or like "still unsure on whether the problems are even solvable" :big_smile:

view this post on Zulip Ayaz Hafiz (Dec 10 2023 at 05:14):

Probably tractable, but I don't really know how to solve them right now

view this post on Zulip Luke Boswell (Aug 13 2024 at 07:32):

I've been trying to track down the latest status on effect interpreters... and this looks like the most relevant thread.

Just wanted to clarify something. Is the type erasure work that Ayaz summarised and Sam was looking at related to effect interpreters?

My loose understanding is that we want to upgrade and have type erasure so we can then implement effect interpreters.

view this post on Zulip Richard Feldman (Aug 13 2024 at 11:03):

yeah, in essence:

view this post on Zulip Luke Boswell (Aug 13 2024 at 11:25):

Thank you for summarising. :grinning:

view this post on Zulip Richard Feldman (Aug 13 2024 at 11:29):

no prob, it's been top-of-mind for a long time - it'll be a huge deal for the language when we have it! :smiley:


Last updated: Jul 06 2025 at 12:14 UTC