[Haskell-cafe] Trouble with indentation
Dougal Stanton
ithika at gmail.com
Wed Jan 9 07:07:44 EST 2008
On 09/01/2008, Fernando Rodriguez <frr149 at easyjob.net> wrote:
>
> However, ghc complains about: parse error on input `=' at the "if m <= 2
> then " line. I believe this is some sort of layout error. Can someone point
> out what I am doing wrong?
Assuming the layout didn't get munged during the email process, the
problem is that the 'if' can't go there. You need to have 'sth = if
...' not 'if cond then sth = '
> diaDeSemana d m a = toEnum num :: DiaSemana
> where
> num = zeller x y z
> zeller x y z = (700 + (26 * x - 2) `div` 10
> + d + y + y `div` 4 + z `div` 4 - 2 * z)
> `mod` 7
> if m <= 2 then
> x = m + 10
> y = (a - 1) `mod` 100
> z = (a-1) 'div' 100
> else
> x = m - 2
> y = a `mod` 100
> z = a `div` 100
Maybe try:
> (x,y,z) = if m <= 2
> then (m+10, (a-1)`mod`100, (a-1)`div`100)
> else (m-2 , a`mod`100, a`div`100)
I haven't tested this though....
--
Dougal Stanton
dougal at dougalstanton.net // http://www.dougalstanton.net
More information about the Haskell-Cafe
mailing list