[Haskell-cafe] Trouble with indentation

Fernando Rodriguez frr149 at easyjob.net
Wed Jan 9 06:52:55 EST 2008


Hi,

I'm trying to write a function that finds out the week day using the Zeller 
congruence (http://en.wikipedia.org/wiki/Zeller's_congruence).

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?

Here's the code:

data DiaSemana = Lunes | Martes | Miercoles | Jueves | Viernes
				| Sabado | Domingo deriving (Show, Eq, Ord, Enum)
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





More information about the Haskell-Cafe mailing list