There are several types of exceptions that could be caught here, but the compiler does not know which one to choose. You could specify a type, but it is easier to use 'onException' (also in Control.Exception) instead of 'catch', if you want to treat all exceptions the same way, without any info about the kind of exception. On Sun, 15 Feb 2015 17:49:21 +0100, Lawrence Bottorff <borgauf@gmail.com> wrote:
Thanks for the tip. Yes, I had tried that, but never got it right. Here's my change: : Stdm02142015.lhs:1037:40-46: No instance for (Exception e1) arising from a use of `catch' The type variable `e1' is ambiguous Possible fix: add a type signature that fixes these type variable(s) Note: there are several potential instances: instance Exception NestedAtomically -- Defined in `Control.Exception.Base' instance Exception NoMethodError -- Defined in `Control.Exception.Base' instance Exception NonTermination -- Defined in `Control.Exception.Base' ...plus 7 others In a stmt of a 'do' block: filedata <- (readFile filename) `catch` (\ _ -> return "") : et cetera, et cetera. Any idea where this import Control.Exception should go. Or is there something else amiss?
On Sun, Feb 15, 2015 at 5:06 AM, Henk-Jan van Tuyl <hjgtuyl@chello.nl> wrote:
On Sat, 14 Feb 2015 23:30:13 +0100, Lawrence Bottorff <borgauf@gmail.com> wrote:
.../Discrete/Stdm02142015.lhs:1036:40-46:
Not in scope: `catch'
.../Discrete/Stdm02142015.lhs:1048:40-46: Not in scope: `catch' Failed, modules loaded: none.
This is on ghci 7.6.3
The function "catch" is removed from Prelude, you need to add the line: import Control.Exception
Regards, Henk-Jan van Tuyl
-- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/