... | ... | @@ -320,6 +320,26 @@ GHC 9.2 has a more accurate pattern-match coverage checker, continuing work that |
|
|
|
|
|
This works because pattern-match coverage-checking works left-to-right, so the `MkT1C` pattern is never reachable as long as one of `MkT2A` or `MkT2B` is matched before it on the left.
|
|
|
|
|
|
* Incomplete irrefutable patterns are warned for under `-Wincomplete-uni-patterns`.
|
|
|
You can avoid such warnings by passing `-Wno-incomplete-uni-patterns` or refactoring the code such that
|
|
|
the compiler sees that the match is not irrefutable.
|
|
|
An obvious example is to turn a pattern `~(Just _)` into `_`; after all, this the former pattern will never lead to a crash.
|
|
|
|
|
|
Another example would be
|
|
|
|
|
|
```hs
|
|
|
foo :: Maybe () -> ()
|
|
|
foo ~(Just a) = a
|
|
|
foo _ = ()
|
|
|
```
|
|
|
In this case a remedy could be to use a case expression at the use site of `a`:
|
|
|
```hs
|
|
|
foo :: Maybe () -> ()
|
|
|
foo m = case m of Just a -> a
|
|
|
foo _ = ()
|
|
|
```
|
|
|
In many cases, the checker is able to see that the `case` is actually a complete match, because `m` might have been scrutinised. In other cases, a catch all alternative throwing an error could be inserted.
|
|
|
|
|
|
---
|
|
|
|
|
|
## Library changes
|
... | ... | |