-
-
Save dmjio/f4dc26786a78757d9028bd2e6eb50423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Exception | |
import GHC.IO.Exception | |
import System.IO.Error | |
main :: IO () | |
main = do | |
result <- tryIOError (readFile "foo") :: IO (Either IOError String) | |
case result of | |
Left e -> | |
case ioeGetErrorType e of | |
NoSuchThing -> putStrLn "no such thing?" | |
x -> print x | |
Right r -> putStrLn r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment