[Haskell-beginners] Indenting

Brent Yorgey byorgey at seas.upenn.edu
Sat Dec 5 11:35:03 EST 2009


On Fri, Dec 04, 2009 at 08:26:52PM +0000, John Moore wrote:
> 
> type Indent = (Int)
> spacing :: Int -> Indent
> spacing n = Nothing
> spacing n (x:xs) = if (n==1)
>                     then (Just n)
>                    else spacing n xs
>                     where (n > 1)

Hmm, you seem to be a bit confused.  What exactly is spacing supposed
to do?  What is its type?  Your type signature says that it has type
Int -> Int, but the second equation spacing n (x:xs) = ...  suggests
that it takes TWO arguments, with the second being a list of some
sort; also, it seems to be returning things of type Maybe Int
(Nothing, Just n).  So, what is it supposed to do?  Is it computing an
*amount* of indentation? Is it supposed to take a String and put
spaces on the front? or...?

-Brent


More information about the Beginners mailing list