News for hackers. Stuff that matters.
Re:I Believe Zig Has Function Colors by feanaro on Saturday April 09, 2022 @07:20AM (#30967069)
I think you're missing the point. The problem of colour is not a problem of limitations. It is indeed a good idea to limit your functions to the least required amount of power via the type system. One great way of achieving this is using an algebraic effects system which someone already linked to elsewhere in this thread.

The problem of colour is rather that even though two functions should have the same structure, regardless of their effects, the language still forces you to write two functions each with its own syntactical structure. In type theory terms, this is a problem stemming from a lack of effect polymorphism.

Ideally you'd write one function, polymorphic in its effects, and then just be able to use it in both sync and async contexts. In the sync context, the function's type would specialize in a way that it lacks the `Async` effect, so it wouldn't be able to do async stuff there. In the async context it would specialize in a way that it does have the `Async` effect. Therein you would be unable to apply it in contexts requiring the lack of an `Async` effect.

Re:I Believe Zig Has Function Colors by staticassertion on Saturday April 09, 2022 @12:19PM (#30969338)
Yes, I probably should have expanded my post to say that an effects system is how this should all be handled.
Re:I Believe Zig Has Function Colors by mjburgess on Saturday April 09, 2022 @11:26AM (#30968842)
ie., we need a color polymoprhism