3 ms·
Non-exhaustive patterns are one thing the compiler can't catch: fn 0 = return () main = fn 1 Giving an empty list to head/tail is another: main = head
by teaspoon 15y ago
Non-exhaustive patterns are one thing the compiler can't catch:
fn 0 = return ()
main = fn 1
Giving an empty list to head/tail is another:
main = head []
- jstepien 15y agoSpeaking of the first example, compiling it with -Wall provides some hints: $ ghc --make test.hs -Wall test.hs:1:1: Warning: Pattern match(es) are non-exhaustive In an equation for `fn': Patterns not matched: #x with #x `notElem` [0#]
- teaspoon 15y agoWow, that's cool. It even works for non-Bounded argument types, as in fn [0] = 0: Warning: Pattern match(es) are non-exhaustive In an equation for `fn': Patterns not matched: [] #x : _ with #x `notElem` [0#] 0# : (_ : _)