[Haskell-cafe] Is there a null statement that does nothing?
thomas.dubuisson at gmail.com
Wed Oct 21 20:47:42 EDT 2009
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"  page I put together
in response to seeing one too many people trip over exactly this issue.
On Wed, Oct 21, 2009 at 5:43 PM, michael rice <nowgate at yahoo.com> wrote:
> 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.
> [michael at localhost ~]$ ghci
> GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help
> Loading package ghc-prim ... linking ... done.
> Loading package integer ... linking ... done.
> Loading package base ... linking ... done.
> Prelude> if (1==1) then else
> <interactive>:1:15: parse error on input `else'
> Prelude> if (1==1) then True else
> <interactive>:1:24: parse error (possibly incorrect indentation)
> Prelude> if (1==1) then True else False
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe