Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like the idea here, but it's a lot further from Haskell than the author implies.

IO expressions in Haskell are values, and that's really important to understand what's going on. It's the reason why things like `timeout :: Int -> IO a -> IO (Maybe a)' can exist. It's not a function marked as being impure somehow. It's a function that takes an IO value and returns an IO value. It is still a pure function. Pass in the same arguments, you get the same value back. Executing the resulting IO action multiple times may do vastly different things each time, but the important part is that executing IO actions is fully independent of evaluating functions.

(Note that monads are completely irrelevant to the above. What makes IO in Haskell different and a big hurdle to learn is that it turns interaction with the world into values that can exist without being executed.)

This proposal... It doesn't let you pass IO values around without executing them. At least it doesn't in its current form. It's not really first-class IO. It's explicit IO, as it eventually calls out. It would be an interesting experiment, but it's a lot less expressive than what Haskell does.



First-class values are values which you can pass as arguments, return as return values, and hold in local variables. Values of type `File` or `TcpStream` are first-class in this sense. They show up in function signatures in the same way as any other first-class values, which is what this blog post is interested in.

This is independent of whether the actual I/O is done via mutation/side-effects/execution/etc. or monads/purity/referential-transparency/etc.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: