[Haskell-cafe] Haskell stacktrace
Donn Cave
donn at avvanta.com
Tue Sep 9 19:11:48 EDT 2008
> 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 at avvanta.com
More information about the Haskell-Cafe
mailing list