
Hi all, I'm having some trouble with IO functions and exceptions. When I call an IO function in Haskell, I feel very uncomfortable, because you never know what kind of exceptions your function may throw. There are a lot of cases where thrown exceptions are not specified in the documentation. What's worse, there are cases where it's impossible to catch thrown exceptions in a safe way. Example to not knowing what exceptions may be thrown: http://hackage.haskell.org/package/base-4.6.0.1/docs/Control-Concurrent-Chan... `readChan` blocks the thread until it reads something. But what happens when channel is closed while one thread is blocked to read? It's not mentioned in the documentation and it's not specified in terms of types. (e.g. by using Either, Maybe or similar) Example to not being able to catch the exception: http://hackage.haskell.org/package/network-2.6.0.2/docs/Network-Socket.html `recvFrom` blocks the thread until it reads something. However, what happens if socket is closed while `recvFrom` is blocking to read? Similar to `readChan`, we can't know this. What's worse is this: sockets have a `SO_RCVTIMEO` option, a timeout value for `recv_from` calls. What happens when we set that using `setSocketOption` in the same module and call `recvFrom` is unknown. This is really horrible, because a timeout exception is really something that you'd like to catch. Example: I have a thread that listens from a socket and handles some other events. I want to stop listening the socket after every second and handle events, then return listening the socket. But I can't know what it throws when timeout happens, so I have to catch all exceptions, which is horrible for a lot of reasons. I was wondering if I'm doing something wrong. I'm sure we can find a lot of cases like these and I feel like libraries are not designed very good for errors/exceptions. So I'd like to get some ideas/suggestions about this. Am I doing something wrong or did I misunderstand something? Should we improve the libraries for better types/error handling? Am I only one here that has problems with those functions? Thanks.