[Haskell-beginners] Top beginner mistakes
7stud
bbxx789_05ss at yahoo.com
Wed Mar 4 16:54:05 EST 2009
Here are my top three:
1) Putting an equals sign after a function name when using guards:
myfunction x y =
| x < 2 = "a"
| y > 20 = "b"
| otherwise = "c"
dhask.hs:2:4: parse error on input `|'
Failed, modules loaded: none.
2) Writing "if" in front of the guard conditions:
myfunction x y =
| if x < 2 = "a"
| if y > 20 = "b"
| otherwise = "c"
dhask.hs:2:25: parse error on input `='
Failed, modules loaded: none.
3) Not putting parentheses around arguments of the form x:xs
dosomething x:xs = head xs
dhask.hs:1:0: Parse error in pattern
Failed, modules loaded: none.
In all three cases, the error messages don't help spot the problem.
More information about the Beginners
mailing list