Skip to content

Instantly share code, notes, and snippets.

@dmjio

dmjio/Main.hs Secret

Created November 1, 2022 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmjio/f4dc26786a78757d9028bd2e6eb50423 to your computer and use it in GitHub Desktop.
Save dmjio/f4dc26786a78757d9028bd2e6eb50423 to your computer and use it in GitHub Desktop.
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