Sat, 6 May 2000 15:30:39 +0400 (MSD), S.D.Mechveliani <[EMAIL PROTECTED]> pisze:
> > | if such a default does not exist then a compile-time error results.
> >
> > The existence of this loop-hole compromises Haskell's static type
> > safety.
I agree that disallowing this would be a good thing.
There are other cases where an omission inserts bottoms:
- non-exhaustive patterns in case and in function definitions,
- creating records.
What about them? Records probably should be disallowed too, and I
have doubts about the former, skewed to "leave it as currently".
I always and fill explicit errors in those cases, but non-exhaustive
patterns often appear during the development. The set of
possible values may be smaller than the type can represent,
then a non-exhaustive pattern is quite natural.
Moreover, there are cases when there is no possibility of specifying
other handlers: lambda, pattern bindings in let, and record updates
("do" already has a special handler). IMHO they certainly should not
be disallowed.
We could put a borderline thus: non-exhaustive patterns are OK, and
they should produce warnings when they can be easily fixed by adding
more cases; other non-exhaustive things should be disallowed.
> If this happens, there will appear more definitions in the
> application programs like
> instance Foo (C a) where foo = dummy_of_some_kind
> -- or maybe = error "..."
> Because it is wrong for the standard classes to pretend for *all*
> their operations to have a real sense in *all* the user instances.
It is not wrong. If this happens often, it means that either the class
definitions are bad or they are used for an inappropriate problem.
> To prohibit this means to prohibit the programming at all.
Of course not.
> The expression zero `asTypeOf` x
> still is, *formally*, not a constant, it depends on x and means
> certain map applied to x.
> The same is zero x
> Also zero x is shorter.
"zero" is yet shorter.
asTypeOf is rarely needed. Moreover, pattern type signatures (a GHC and
Hugs extension) can be used instead of asTypeOf when the type is not
known statically, where it's clear that we only disambiguate the type.
> This critic looks strange: searching for problems where there are
> not any.
> Alfred defined *his* user type T and *his* Set instance for it.
> And Charles dislikes this instance.
> Why basAlgPropos is guilty?
Because it unnecessarily forced him to define a Set instance, and to
do it early.
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/ GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-