Pondering Effects

22 points by icefox


jjw

I’m pretty sure the “effects on data” that you’re talking about is modelled by coeffects, which have a wonderful introductory tutorial at https://tomasp.net/coeffects/

typesanitizer

Zig is not that unique in you having to pass around something fairly "fundamental" in a way. Go is a higher-level language, but it requires explicitly plumbing a Context object for cancellation (and you need to check it manually). Go codebases where you pass the logger explicitly introduce more verbosity, sure, but because of the way, interface subtyping works, you could fold the Logger and Context into a single parameter that gets silently narrowed depending on what's needed.

A bigger problem with effects as I see it (and have covered in https://typesanitizer.com/blog/effects-convo.html) is that it becomes a breaking change to do a variety of useful things like adding assertions, instrumenting your code for coverage points for tests (e.g. what matklad has written about as "coverage marks") and so on, without punching a hole through the effect system.