
On Tue, Nov 22, 2011 at 4:35 AM, Michael Craig
... but of course this doesn't compile, because the types of the LHSs in the case statement are different. I can get around it with some ugliness ... handleErrors :: SomeException -> Iteratee a m String handleErrors ex = case fromException ex of Just POSTOnlyException -> return "POSTs only!" _ -> case fromException ex of Just BadPathException -> return "Bad path!" _ -> return "Unknown exception!" ... but there must be a better way. Enlighten me?
If you enable the ViewPatterns extension {-# LANGUAGE ViewPatterns #-} then you can write handleErrors as handleErrors :: SomeException -> Iteratee a m String handleErrors (fromException -> Just POSTOnlyException) = return "POSTs only!" handleErrors (fromException -> Just BadPathException) = return "Bad path!" handleErrors _ = return "Unknown exception!" Cheers, -- Felipe.