Input Processing Loops in Haskell
Simon Marlow
simonmar@microsoft.com
Wed, 14 Nov 2001 11:36:19 -0000
> On Tue, Nov 13, 2001 at 05:02:54PM -0000, Simon Marlow wrote:
> >=20
> > You can paraphrase this in Haskell, in the IO monad, like this:
> >=20
> > loop =3D do {
> > a <- get_input;
> > if (a =3D=3D gET_OUT) then return () else loop;
> > }
>=20
>=20
> I follow, but I've never seen brackets used in Haskell code. Are they
> included for clarity, or do they have syntactic value? Is=20
> this the same
> as
>=20
> loop =3D do=20
> a <- get_input
> if (a =3D=3D GET_OUT) then return () else loop
>=20
> ?
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