How do I correctly use Control.Exception.catch in Haskell?
问题 Can someone please explain the difference between the behavior in ghci of the following to lines: catch (return $ head []) $ \(e :: SomeException) -> return "good message" returns "*** Exception: Prelude.head: empty list but catch (print $ head []) $ \(e :: SomeException) -> print "good message" returns "good message" Why isn't the first case catching the exception? Why are they different? And why does the first case put a double quote before the exception message? Thanks. 回答1: Let's examine