RE: Input Processing Loops in Haskell

On Tue, Nov 13, 2001 at 05:02:54PM -0000, Simon Marlow wrote:
You can paraphrase this in Haskell, in the IO monad, like this:
loop = do { a <- get_input; if (a == gET_OUT) then return () else loop; }
I follow, but I've never seen brackets used in Haskell code. Are they included for clarity, or do they have syntactic value? Is this the same as
loop = do a <- get_input if (a == GET_OUT) then return () else loop
?
Yes, it's the same. Some people prefer to use the explicit punctuation; personally I use whatever looks more readable for the code I'm writing, which in most cases means I use layout for small functions but punctuation for large chunks of code where it's hard to see which bits line up. Cheers, Simon
participants (1)
-
Simon Marlow