[Haskell-beginners] Best practice for catching pure errors in IO?

John Smith voldermort at hotmail.com
Wed Oct 27 02:45:13 EDT 2010


I have a pure value which may throw errors when it is evaluated in an IO monad. My code to handle it looks like this:

temp <- try $ evaluate value
case temp of
	Left (error::ErrorCall) -> scoldTheUserAndTryAgain
	Right correct -> doSomething

Can this be done without the temporary variable, or with less plumbing? I tried lifting either, but GHC was fussing 
about ambiguous types, appending a signature to a pattern match is no longer allowed(?), and it didn't look that much 
cleaner.



More information about the Beginners mailing list