Inside 214-1E

Existential Pontification and Generalized Abstract Digressions

Lazy exceptions and IO

Consider the following piece of code: import Prelude hiding (catch) import Control.Exception main :: IO () main = do t <- safeCall unsafeCall t putStrLn "Done." safeCall :: IO String safeCall = do return alwaysFails `catch` errorHandler --alwaysFails = throw (ErrorCall "Oh no!") alwaysFails = error "Oh no!" errorHandler :: SomeException -> IO String errorHandler […]

  • May 24, 2010