I have started working my way through Erik Meijer's 13-part lectures (and Graham Hutton's slides) to learn Haskell.
On the slides for Chapter 4, on page 13, it introduces the pattern-matching syntax for n+k patterns. In particular, it says:
As in mathematics, functions on integers can be defined using n+k patterns, where n is an integer variable and k>0 is an integer constant.
pred :: Int -> Int
pred (n+1) = n
When I tried this on my own in the REPL I get an error message:
*Main> let mypred (n+1) = n
<interactive>:65:13: Parse error in pattern: n + 1
Similarly, if I try it in a *.hs
file
mypred :: Int -> Int
mypred (n+1) = n
The compiler gives a similar complaint:
/Users/pohl/Code/praxis-haskell/helloworld.hs:14:9:
Parse error in pattern: n + 1
Am I not understanding how n+k patterns are intended to be used?