Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-27 Thread Brent Yorgey
On Wed, Oct 21, 2009 at 07:49:14PM -0500, Tim Wawrzynczak wrote: Yes, an if statement must have both 'then' and 'else' branches. As an example, what if you had let a = if b == 2 then True else False and you were missing an else branch? What would 'a' get assigned to? The if statement

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-27 Thread Kim-Ee Yeoh
Hi Brent, Re: 'if expressions, not statements' is an elegant clarification, one definitely for the haskellwiki, if not there already. Just for completeness' sake, bottom is a value for any expression. Wouldn't making the else clause optional by defaulting to undefined worthy of consideration

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-27 Thread Evan Laforge
On Tue, Oct 27, 2009 at 10:08 AM, Kim-Ee Yeoh a.biurvo...@asuhan.com wrote: Hi Brent, Re: 'if expressions, not statements' is an elegant clarification, one definitely for the haskellwiki, if not there already. Just for completeness' sake, bottom is a value for any expression. Wouldn't

Re[2]: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-27 Thread Bulat Ziganshin
Hello Kim-Ee, Tuesday, October 27, 2009, 8:08:27 PM, you wrote: Just for completeness' sake, bottom is a value for any expression. Wouldn't making the else clause optional by defaulting to undefined worthy of consideration for Evil Haskell? in this case you will get an exception when

Re: Re[2]: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-27 Thread Svein Ove Aas
On Tue, Oct 27, 2009 at 7:07 PM, Bulat Ziganshin bulat.zigans...@gmail.com wrote: Hello Kim-Ee, Tuesday, October 27, 2009, 8:08:27 PM, you wrote: Just for completeness' sake, bottom is a value for any expression. Wouldn't making the else clause optional by defaulting to undefined worthy of

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-25 Thread michael rice
Hi Curt, Thanks for the tips. Looks like return () would be a good candidate for that null statement I was seeking earlier. Michael --- On Sun, 10/25/09, Curt Sampson c...@starling-software.com wrote: From: Curt Sampson c...@starling-software.com Subject: Re: [Haskell-cafe] Is there a null

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-24 Thread Henning Thielemann
Dan Weston schrieb: If you have a long if/else if/else chain, you might consider a trivial case statement with guards. Whether you think this is attractive is a matter of taste, but it has the fall-through semantics you want and ghc optimizes the _ pattern matching away: f x = case () of

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-24 Thread Curt Sampson
On 2009-10-21 18:27 -0700 (Wed), michael rice wrote: Those nested IF/THEN/ELSEs are real killers. I kind of use them to sort out my thoughts, then end up with a nested mess. The restructuring to WHENs went smoothly and looks a lot cleaner besides. Indeed. Monadic control flow is one of the

Re[2]: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-22 Thread Bulat Ziganshin
in a row and nothing between them. Oh, well, on to restructuring. Michael --- On Wed, 10/21/09, Tim Wawrzynczak inforichl...@gmail.com wrote: From: Tim Wawrzynczak inforichl...@gmail.com Subject: Re: [Haskell-cafe] Is there a null statement that does nothing? To: michael rice nowg...@yahoo.com Cc

[Haskell-cafe] Is there a null statement that does nothing?

2009-10-21 Thread michael rice
It looks like both the THEN and the ELSE in an IF expression must each have an expression. What's a graceful way to do nothing in either or both slots, kind of like the Fortran CONTINUE statement.   --mr [mich...@localhost ~]$ ghci GHCi, version 6.10.3:

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-21 Thread Thomas DuBuisson
If its monadic code then use Control.Monad.when. If its pure code then omitting the 'else' clause makes no sense what-so-ever; to omit the else you must know the boolean is always true so why have the if? See the Common Misunderstandings [1] page I put together in response to seeing one too many

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-21 Thread Tim Wawrzynczak
Yes, an if statement must have both 'then' and 'else' branches. As an example, what if you had let a = if b == 2 then True else False and you were missing an else branch? What would 'a' get assigned to? The if statement returns a value so must have both branches. However, in a monadic

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-21 Thread michael rice
wrote: From: Tim Wawrzynczak inforichl...@gmail.com Subject: Re: [Haskell-cafe] Is there a null statement that does nothing? To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Wednesday, October 21, 2009, 8:49 PM Yes, an if statement must have both 'then' and 'else' branches

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-21 Thread Dan Weston
, on to restructuring. Michael --- On *Wed, 10/21/09, Tim Wawrzynczak /inforichl...@gmail.com/* wrote: From: Tim Wawrzynczak inforichl...@gmail.com Subject: Re: [Haskell-cafe] Is there a null statement that does nothing? To: michael rice nowg...@yahoo.com Cc: haskell-cafe

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-21 Thread michael rice
...@imageworks.com Subject: Re: [Haskell-cafe] Is there a null statement that does nothing? To: michael rice nowg...@yahoo.com Cc: Tim Wawrzynczak inforichl...@gmail.com, haskell-cafe@haskell.org haskell-cafe@haskell.org Date: Wednesday, October 21, 2009, 9:16 PM If you have a long if/else if/else