[Haskell-beginners] let indenting problems

7stud bbxx789_05ss at yahoo.com
Mon Mar 2 03:51:39 EST 2009


I get indenting errors with the following attempts to use let:

-----
import Data.List (sortBy)

mySort xs = sortBy myCompare xs
    let lx = length x
        ly = length y
    in where myCompare x y 
              | lx < ly    = LT    
              | lx == ly   = EQ
              | lx > ly    = GT  

------------------

import Data.List (sortBy)

mySort xs = sortBy myCompare xs
    where myCompare x y    
        let lx = length x
            ly = length y
        in

        | lx < ly    = LT
        | lx == ly   = EQ
        | lx > ly    = GT  

-------------

import Data.List (sortBy)

mySort xs = sortBy myCompare xs
    where myCompare x y    
        let lx = length x
            ly = length y
        in  | lx < ly    = LT
            | lx == ly   = EQ
            | lx > ly    = GT 

-------------


This is what I ended up with:

-------
import Data.List (sortBy)

mySort xs = sortBy myCompare xs
    where myCompare x y  
              | lx < ly    = LT
              | lx == ly   = EQ
              | lx > ly    = GT            
             where lx = length x
                   ly = length y
-------

But I would like to know how to use let.







More information about the Beginners mailing list