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-