Do we have to use parentheses in pattern matching in function declarations ?
In example below, I have a pattern x:xs where x takes first el
Parentheses are not part of pattern matching, in the same sense that they are not part of expression evaluation. That being said, parentheses are certainly part of pattern and expression syntax.
Look, if you write
h x:xs
this looks like
(h x) : xs
to the parser. Hence we write
h (x:xs)
both on the left hand side and on the right hand side of the equal sign. As expression, it means "function h applied to a list constructed of x and xs", and on the left hand side it defines an equation for that application.