Hacker News new | ask | show | jobs
by the_af 1648 days ago
I 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!

1 comments

I 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)

Agreed, and as another person commented, a logging system doesn't actually need to live in the (too broad) IO monad.