4 ms·
I like this and have a similar frame of mind. I wish more languages would make their sum types true duals of their structs (with a single payload datum - instea
by andyferris 2y ago
I like this and have a similar frame of mind. I wish more languages would make their sum types true duals of their structs (with a single payload datum - instead we have tuple variants and structure variants and so-on complicating matters for at best a character of syntax (but careful design could eliminate even that).
The author may be interested in coeffects as the dual of effects. They are pretty much as stated: coeffects are the context environment the that program executes in. This link has some prototypes of languages that let you create coeffects in your code: https://tomasp.net/coeffects/ https://tomasp.net/coeffects/
I was going to bring up covariance vs contravariance but the author mentions they were skipped for brevity.
Finally I really think simplifying to the point we ignore the idea of consumed-produced values is unfortunate. Consider how “inout” parameters aren’t too much different to a mutable reference (though the change in binding may be more explicit in a pure functional language). From the article it’s pretty clear why inout/reference parameters need to be invariant (both covariant and contravariant). And there is a whole lot that this kind of reasoning can bring to understanding Rust’s borrow checker and possibly how to create something simpler with the same strengths. But for that we’d need to model immutable references, unique mutable references and dare I say also volatile references (the environment IS volatile, whether it’s your physical peripherals or your application database, and IMO not having a language construct for that makes life harder than needs be).
- Joel_Mckay 2y agoThe Erlang OTP handles the issue of data state reconciliation in a rather robust manner. However, this does not span all possible use-cases efficiently. Have a great day =3
- iLemming 2y agoThe best practical understanding of Petricek's work I gained from using Clojurescript's Re-frame library. In re-frame, coeffects represent the data that an event handler needs from the outside world to do its job (like current time, random numbers, or local storage values). This aligns with the academic concept of tracking contextual dependencies, just applied practically in a front-end framework context. The main difference is that re-frame uses a more pragmatic, simplified version focused specifically on event handling in web applications, rather than the full mathematical formalism of the academic work. Learning re-frame was a light-bulb moment for me. I highly recommend giving it a try, even if there's never a plan to use Clojure or Clojurescript in practice.