Skip to content

Warning about redundant bang patterns

Motivation

I have seen pattern matches like this one in Haskell code:

f !(Cons a b c) = ...

The bang pattern on Cons is unnecessary since if you pattern match on Cons the argument is evaluated to weak head normal form, anyway.

The programmer might expect that ! performs a deep evaluation or just hopes that random addition of ! to some arguments may improve speed or memory consumption.

Proposal

Please add a warning for redundant bang patterns and add it to -Wall.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information