--- On Wed, 8/27/08, Dan Weston <[EMAIL PROTECTED]> wrote:
> 
> Failure to handle a null pointer is just like using
> fromJust and results 
> in the same program termination (undefined).
> 
> Dan
> 

Well, not (IMHO) 'just like': 'fromJust Nothing' turns into a 'catchable' 
exception in the IO Monad, but a SEGFAULT certainly doesn't.

E.g.
> import Control.Exception as C
> import Data.Maybe
> main = do
>    (fromJust Nothing >>= ( \ s -> putStrLn s)) `C.catch` 
>        (\ _ -> putStrLn "ok")

prints 'ok', whereas:

> import Foreign.Ptr
> import Foreign.Storable
> import qualified Control.Exception as E
> main = poke nullPtr '\0' `E.catch` (\ _ -> putStrLn "ok")

just segfaults...





      
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to