News for hackers. Stuff that matters.
Re:Moving Beyond Type Systems by wavemode on Friday May 31, 2024 @10:16PM (#40542320)
Effect systems have always felt to me like the functional programming community re-inventing dependency injection, but at the type level.

At the term level, you could just let your function have a function as a parameter `read_file: IO -> String`, vs. annotating it with some kind of type-level "filesystem effect". And the former is a lot more flexible over time.

Re:Moving Beyond Type Systems by mitt_romney_12 on Friday May 31, 2024 @11:54PM (#40542741)
This is an interesting approach but it has some issues with more more advanced effects. For example if you have a function that uses mutable state you would need to have the state both as an input and an output (for the original and the updated state) `update_mut: State -> String -> State` this isn't very economical as is probably worse than just `update_mut: String -> State ()`. If you commit to just having the parameters act as "markers" that don't actually relate to the implementation then you can get away with `update_mut: State -> String -> ()` but then you use one of the big benefits of effect systems which is that you can change the way effects work and have multiple different implementations.
Re:Moving Beyond Type Systems by 12_throw_away on Saturday June 01, 2024 @04:25PM (#40548802)
> Effect systems have always felt to me like the functional programming community re-inventing dependency injection

Yeah, so, in python, I've been playing around with "structured dependency injection", basically DI + ideas from structured concurrency (i.e., dependency injection bound to well-defined lexical scopes). And whenever I read about effects systems, it definitely feels like they're talking about, if not the same thing, at least something in the same nuclear family of things.