[Haskell-cafe] Re: IO exception not being caught

Simon Peyton-Jones simonpj at microsoft.com
Wed Nov 16 11:19:55 EST 2005


Indeed!  I always use braces and semicolons with do-notation.  You are
free to do so too!  Nothing requires you to use layout. Indeed, you can
freely mix the two.

Simon

| -----Original Message-----
| From: haskell-cafe-bounces at haskell.org
[mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Joel
| Reymont
| Sent: 16 November 2005 15:37
| To: Haskell Cafe
| Subject: [Haskell-cafe] Re: IO exception not being caught
| 
| After almost two months with Haskell I'm starting to understand why
| its use is not as widespread as... well pick a favorite language of
| your own. My issue was that of indentation.
| 
| Compare this working version:
| 
| liftIOTrap io =
|      do mx <- liftIO (do x <- io
|                          return (return x)
|                       `catchError`
|                       (\e -> do let x = fromIOError e
|                                 trace_ $ "Caught " ++ x
|                                 return $ throwError x
|                       ))
|         mx
| 
| With the one below
| 
| On Nov 16, 2005, at 2:27 PM, Joel Reymont wrote:
| 
| >> liftIOTrap io =
| >>     do mx <- liftIO (do x <- io
| >>                         return (return x)
| >>                                    `catchError`
| >>                                    (\e -> return (throwError
| >>                                                   (fromIOError
e))))
| >>        mx
| 
| --
| http://wagerlabs.com/
| 
| 
| 
| 
| 
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe at haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list