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 condition is false (when
'if' used in expression)


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


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 consideration for Evil Haskell?

 in this case you will get an exception when condition is false (when
 'if' used in expression)

Yes, that's why it's evil.

Or.. I know!

ifWithoutElse :: a - Bool - Maybe a

(Wait...)
-- 
Svein Ove Aas
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2009-10-22 Thread Bulat Ziganshin
Hello michael,

Thursday, October 22, 2009, 4:59:43 AM, you wrote:

return () does the trick if another branch also returns ()

 Thanks guys,

 I understand what you're telling me, but have some nested IFs and
 just want to fall through on one of the ELSES but then I end up with
 two ELSES 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@haskell.org
 Date: Wednesday, October 21, 2009, 8:49 PM

 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 constraint, there are the functions 'when'
 and 'unless.'  They allow conditional evaluation of expressions in a monadic 
 context.  For example,
  
 main = do
   line - getLine
   when (line == hello) putStrLn Hello back!

 Cheers,
  - Tim


 On Wed, Oct 21, 2009 at 7:43 PM, michael rice nowg...@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. 

   --mr

  

 [mich...@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
 True
Prelude 


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


  


   


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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