4 ms·
Sadly the effect system isn't granular to narrow down what effect is happening other than "IO", which could be logging, network, disk access, rm -rf /. And with
by discodachshund 5y ago
Sadly the effect system isn't granular to narrow down what effect is happening other than "IO", which could be logging, network, disk access, rm -rf /. And without that visibility it doesn't provide you much advantage.
Haskell similarly suffers, I'd like to see IO broken down into composable units of functionality so I can see if e.g. my logging library has some ridiculous network constraint.
- the_af 5y agoI suspect the same re: this library: IO is indeed too broad, and a logging system needs to do IO. You could use other monads though. > Haskell similarly suffers Haskell practitioners aim to write as much code as possible outside the IO monad. If everything you write lives inside that monad, what's the benefit? The nice thing about Haskell is that if you write every function with IO in its signature, it's bound to raise eyebrows in code reviews, whereas in most other mainstream languages everything lives in an IO monad by default!
- thowaway202107 5y agoI think the point was that for that remaining bit that can’t be extracted into pure functions still is really broad in what it can do with just “IO” IO on it’s own could mean disk, network, environment variables, sub processes, etc. My take away is that they’d like to see IO defined as the union of its parts that can also be decomposed, so you’d have a DiskIO monad or ExecIO That way you can be more certain that you’re not accidentally going to do a bunch of network io before your sub process kicks off. Right now you can’t have that guarantee (out of the box, at least. idk if there’re any user land libraries to do such a thing)
- the_af 5y agoAgreed, and as another person commented, a logging system doesn't actually need to live in the (too broad) IO monad.
- still_grokking 5y agoWho isn't waiting to finally get an usable effect system? But there is something on the horizon for Scala: https://github.com/lampepfl/dotty/blob/release-3.1.0/docs/docs/reference/experimental/canthrow.md#outlook https://github.com/lampepfl/dotty/blob/release-3.1.0/docs/do... One can have a proper effect system on the JVM also already today with Flix: https://en.wikipedia.org/wiki/Flix_(programming_language)#Polymorphic_effects https://en.wikipedia.org/wiki/Flix_(programming_language)#Po...