PmCheck treats Newtype patterns the same as constructors
Consider the following program:
module Lib where
data T1 a = T1 a
newtype T2 a = T2 a
f :: T1 a -> Bool -> ()
f _ True = ()
f (T1 _) True = ()
f _ _ = ()
g :: T2 a -> Bool -> ()
g _ True = ()
g (T2 _) True = ()
g _ _ = ()
This generates the following warnings:
test2.hs:10:1: warning: [-Woverlapping-patterns]
Pattern match has inaccessible right hand side
In an equation for ‘f’: f (T1 _) True = ...
|
10 | f (T1 _) True = ()
| ^^^^^^^^^^^^^^^^^^
test2.hs:15:1: warning: [-Woverlapping-patterns]
Pattern match has inaccessible right hand side
In an equation for ‘g’: g (T2 _) True = ...
|
15 | g (T2 _) True = ()
| ^^^^^^^^^^^^^^^^^^
But while f undefined False
certainly leads to a crash, g undefined False
does not, with or without the second clause of g
! So really the clause is redundant.