Built based on Daniel Wagner's answer:
import Control.Exception
import Data.Typeable
whichException :: IO a -> IO ()
whichException act = do
e <- try act
case e of
Left (SomeException ex) -> print $ typeOf ex
_ -> putStrLn "No exception occurred"
-- Usage:
-- > whichException (evaluate (read "A"::Int))
-- ErrorCall
source
share