
9 Sep
2008
9 Sep
'08
11:11 p.m.
This : Prelude> let f = (\x -> return "something went wrong") :: IOError -> IO String Prelude> let t = return $ show $ "too short list" !! 100 :: IO String Prelude> catch t f "*** Exception: Prelude.(!!): index too large
doesn't work.
You might be interested in the difference between Prelude.catch and Control.Exception.catch Though in an example like that, you'll need to force evaluation to actually catch the exception. f _ = return "something went wrong" t = return $! show $ "too short list" !! 100 ... Control.Exception.catch t f (note $! instead of $ in "t".) Donn Cave, donn@avvanta.com