[Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app
Eric Seidel
eric at seidel.io
Tue Jan 31 17:31:13 UTC 2017
> Note that
>
> case <foo>
> | [] -> ...
> | (_ : xs) -> ...
>
> also contains a wildcard-pattern. So emitting a warning for every use
> of wildcard patterns would likely lead to a lot of pain.
Yes, good point, that would be too restrictive. When I said wildcard-pattern I was thinking specifically of a top-level wildcard, so your example would be accepted, but e.g.
case ... of
[] -> ...
_ -> ...
would be rejected.
> You'd instead want to warn about "default branch", e.g.
>
> case <foo>
> | [] -> ...
> | (1 : xs) -> ...
> | (_ : xs) -> ...
>
> here the wildcard pattern does correspond to a "default branch" and
> might hence deserve a warning.
This sounds promising, but how would you define “default branch”? Seems like it could be an involved definition, which could make the warning unpredictable for users.
More information about the Haskell-Cafe
mailing list