[Haskell-cafe] Haskell newbie indentation query.

Ramaswamy, Vivek Vivek.Ramaswamy at FMR.COM
Wed Oct 15 07:39:54 EDT 2008


Hello All~

I have just started with Haskell, and I must confess; I am in love with
it.
However one area that I am really confused about is indentation.
Lets take a look at if-else if- else block.

The way I understand it:
{------}
if something
 then do 
  something 1
  something2
else if nothing
 then do 
  something3
  something4
else do 
 different
{-------}
The code above gives out an error.  I have been programming in python
and the above appears fine.
But it does not work.
What works is: 
if something
 then do
  something1
  something2
  else if
   then do
    something3
    something4
    else do
     different

I find the above scheme extremely confusing. I tried going to: 

http://en.wikibooks.org/wiki/Programming:Haskell_indentation after
reading I am even more confused.
Can somebody please explain how the Haskell indentation works?

The else-if and else seem to be aligning up with "then". They should be
aligning with "If" in my opinion.
	
Thanks in advance.


Regards
-Vivek Ramaswamy-




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081015/bdcb0486/attachment.htm


More information about the Haskell-Cafe mailing list