If I understood rightly, exceptions in Haskell basically intended to deal within IO monad. At least exception could be caught inside IO monad.
But sometimes even pure functions may throw an exception, e.g. read "..." :: Int
(when reading string does not represent integer), operator (!!)
(when we trying to get item out of range of the list), and so forth. And this is true behavior, I don't deny. However, I would not want to change signature of function just to get it chance to catch possible exception, because in this case I have to change signature all the functions by call stack before.
Is there some pattern to deal with exceptions more comfortable in Haskell, out of IO monad? May be I should use unsafePerformIO
in this case? How "safe" to use unsafePerformIO
just for catching exceptions in pure functions?