Pattern match checking, bang patterns and newtypes
Here's another bugger:
{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-}
{-# LANGUAGE BangPatterns #-}
module Lib where
newtype IInt = IInt Int
f :: IInt -> Bool -> ()
f !(IInt _) True = ()
f (IInt 42) True = ()
f _ _ = ()
warns
blub.hs:9:1: warning: [-Woverlapping-patterns]
Pattern match has inaccessible right hand side
In an equation for ‘f’: f (IInt 42) True = ...
|
9 | f (IInt 42) True = ()
| ^^^^^^^^^^^^^^^^^^^^^
Which is too imprecise: Actually the line is redundant. If you delete it, f (IInt $ error "boom") True
will still crash.