
17 Aug
2017
17 Aug
'17
3:55 a.m.
I'm trying to use catch (...) (\e -> putStrLn $ show e) However, I get an error Ambiguous type variable ‘a0’ arising from a use of ‘show’ prevents the constraint ‘(Show a0)’ from being solved. This goes away if I change the code to catch (...) (\e -> putStrLn $ show (e::IOException)) A couple of things I don't understand here: - The signature for catch begins "Exception e", and exception it "class (Typeable e, Show e) => Exception e". So why isn't show automatically available? - Why does the new code work at all? e is Exception, not IOException. What would happen if it caught a different Exception?