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

2005-11-16 Thread Simon Peyton-Jones
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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 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@haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2005-11-16 Thread Bulat Ziganshin
Hello Joel,

Wednesday, November 16, 2005, 6:37:25 PM, you wrote:

JR After almost two months with Haskell I'm starting to understand why  
JR its use is not as widespread as... well pick a favorite language of  
JR your own. My issue was that of indentation.

just enclose potentially problematic do ... in parentheses:

JR liftIOTrap io =
JR  do mx - liftIO (do x - io
JR  return (return x)

can be written as

do mx - liftIO ((do x - io
return (return x))

and after that you can put `catchError` to any position in the line




-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



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