[Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app
svenpanne at gmail.com
Tue Jan 31 07:43:31 UTC 2017
2017-01-31 7:45 GMT+01:00 Saurabh Nanda <saurabhnanda at gmail.com>:
> We want this at my company too, so we don't write fall-through cases.
> That's a short-term workaround, yes. However it doesn't fit into Haskell's
> overall story of language-enforced correctness.
I don't see this as a workaround, this is *the* way to go IMHO. Using '_'
is saying: "I know what I'm doing here, for all eternity, trust me...", so
you get what you ask for. Unless you don't care about an argument at all,
using '_' is counterproductive for maintenance. But that's the usual
tension between being able to write something down quickly which works
*now* and writing something which will be maintained for a long time by
lots of people. So '_' itself is fine, but you should be aware of what kind
of SW you are writing. Implicitness will always hurt you sooner or later,
it is only a matter of time, and '_' has a very implicit flavor.
For exactly this reason, using C++'s "default" case was banned in the last
2 companies I've worked for, and this turned out to be very beneficial:
Finding all the places where a "default" was not really the default anymore
hit us several times and resulted in actual bugs in released SW. Banning
'_', just like Christopher mentioned, seems to be a sensible approach.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe