haskell-src-exts: Ticket #209: Negative pattern parsing
http://trac.haskell.org/haskell-src-exts/ticket/209
<p>
One of the constructors for the <tt>Pat</tt> type is <tt>PNeg Pat</tt>, for negated patterns. But not only is the <tt>Pat</tt> field here way too general (since <tt>-n</tt> or <tt>-(x:xs)</tt> are not valid patterns), the only circumstances in which it *is* actually valid seem to be negated literals, which are either quite capable of storing that information in their literal, or quite inappropriate to be negated (and so should be an error). Notice that <tt>-1##</tt> is a <i>parse</i> error in GHC since word literals must be <i>non-negative</i> integers.
</p>
<p>
So there's firstly an arguable bug in that <tt>parsePat "-'a'"</tt> succeeds, producing <tt>ParseOk (PNeg (PLit (Char 'a')))</tt> which is nonsense, but there's also a wider question of whether we need <tt>PNeg</tt> at all, or whether we can drop it in favour of negation inside the literals. <tt>NegApp</tt> is clearly necessary on expressions, but there's no analogous negation of variables or compound constructions in patterns.
</p>
en-ushaskell-src-extshttp://trac.haskell.org/haskell-src-exts/chrome/common/trac_banner.png
http://trac.haskell.org/haskell-src-exts/ticket/209
Trac 0.11.1