@albertdahlin, I would recommend looking into papers on “effect systems” and “effect types” to get a sense of the ideas that have been tried out. I remember really liking Koka from Daan Leijen, and Elm’s records are based on one of his earlier papers.
Two potentially interesting data points:
- When doing the design for
Cmd, I considered using something like OCaml’s “polymorphic variants” to have a permissions system for commands. Instead it might have beenCmd [Http,Time] Msgor something like that. Ultimately we did not think the complexity/usefulness balance was right for Elm specifically. - I believe PureScript used to have
Eff { ... } ainstead ofIO aand they eventually dropped the effect restriction part. This is something I half-remember hearing, and I guess it’s true based on this?
That’s not to say this is a bad idea or anything! Just that people have struggled to get the right balance of complexity/usefulness right in some prior efforts I know about. Daan Leijen is really good at looking at a complex research problem and finding a very simple approach that feels like a great balance. That said, I haven’t been following “effect systems” research for a few years now, so hopefully there is enough in this post to be a workable starting point for looking into more prior work!