Skip to content

Instantly share code, notes, and snippets.

@sshine
Created January 31, 2021 18:16
Show Gist options
  • Save sshine/0d4d7bd8e480ad44c5ded71ad12978eb to your computer and use it in GitHub Desktop.
Save sshine/0d4d7bd8e480ad44c5ded71ad12978eb to your computer and use it in GitHub Desktop.
exceptionHandler :: SomeException -> IO ()
exceptionHandler (SomeException (e @ IOError{})) = T.putStrLn (T.pack (show e))
exceptionHandler (SomeException e) = T.putStrLn (T.pack (show (typeOf e)))
{-
• Couldn't match expected type ‘e’ with actual type ‘IOException’
‘e’ is a rigid type variable bound by
a pattern with constructor:
SomeException :: forall e. Exception e => e -> SomeException,
in an equation for ‘exceptionHandler’
at app/Main.hs:34:19-47
• In the pattern: IOError {}
In the pattern: SomeException (e@IOError {})
In an equation for ‘exceptionHandler’:
exceptionHandler (SomeException (e@IOError {}))
= T.putStrLn (T.pack (show e))
• Relevant bindings include e :: e (bound at app/Main.hs:34:34)
|
34 | exceptionHandler (SomeException (e @ IOError{})) = T.putStrLn (T.pack (show e))
| ^^^^^^^^^
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment