Pattern syntax error message vague / pattern syntax overly restricted
Motivation
@cgibbard and I checked
{-# LANGUAGE #-}
data WeirdTree = Leaf | (:+) WeirdTree WeirdTree WeirdTree
f Leaf = 0
f ((t :+ t') t'') = 1
gives
weirdtree.hs:4:4: error: Parse error in pattern: (t :+ t')
|
4 | f ((t :+ t') t'') = 1
| ^^^^^^^^^^^^^
Proposal
Firstly, I think this a bad error message. We could say something like "application head in pattern must be a data constructor", which is more precise.
However, we also are skeptical of the inflexibility of the current rules. Why not allow more parens to match the expression syntax? If there isn't a show-stopper we aren't aware of, perhaps it's worth writing a ghc-proposal for.
CC @int-index this vaguely reminds me of the stuff we talked about in https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0228-function-result-sigs.rst . There is also the looming issue of parsing patterns with lower case data constructors with -XUnifiedTypes
.