[Haskell-cafe] if-then without -else?
neil_mayhew at users.sourceforge.net
Mon Jul 9 21:22:08 UTC 2018
On 2018-07-09 12:54 PM, Olga Ershova wrote:
> In hindsight, maybe non-exhaustive case expression should be errors,
> not warnings. But then adding new constructor to the type could break
> existing code in multiple places, even if constructor is never used.
> Not everybody ready to pay this price.
You make a good point, and this is the best explanation I've seen in
this discussion. However, even if the constructor is never used in your
own code, it may well be used in library code that you call. I think
it's dangerous for for the programmer not to know when a new constructor
is added. I prefer to have this warning enabled, and my policy is to use
-Wall -Werror from the start of any new project. I then turn off
specific warnings (eg orphans) with a pragma in individual source files
when I really need to use something.
I was interested to see that GHC allows you to turn any warning into an
error, so I assume Haskell could be made total for pattern matching with:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe