The error message says it was impossible to figure out the type of exception (that is, the instance of Exception
) you want to catch. One possible solution is providing a type annotation which specifies it, as in:
case (input :: Either IOError String) of
Left e -> print "a"
Right r -> print "b"
Alternatively, if you use isDoesNotExistError
and friends in System.IO.Error
to distinguish the error cases the exception type will be inferred as IOError
without requiring extra annotations.
A relevant discussion of basic exception catching practices can be found in the Control.Exception
documentation.