Erik Meijer wrote:
| > b) if you add an extra constructor to a single-constructor type
| > then pattern matches on the original constructor suddenly become
| > failable
|
| That is great. I'd rather have this as a static error that getting an
| unexpected pattern match failure in my nuclear reactor device driver:
|
| data Position = Open | Close
| controlReactor = do{ .....; Open <- checkValve; ... }
|
| than have this fail silently using the default definition mfail = undefined.
I agree with this completely.
Many of the proposed changes (such as renaming of the overloaded monad
operators, MonadZero, etc.) are proposed because they often bite
naive programmers.
A much-heard argument against this is: "make the error messages better".
In the case of MonadZero, I fully agree. If the compiler said:
Type Error:
In function: controlReactor
Of type: Reactor ()
Because: Reactor is not an instance of MonadZero
<= The pattern "Open" is not unfailable
<= The datatype "Position" has more than one constructor.
Nobody would complain about this, it is clear where the error comes from.
Regards,
Koen.
--
Koen Claessen,
[EMAIL PROTECTED],
http://www.cs.chalmers.se/~koen,
Chalmers University of Technology.