Revamping the numeric classes

Marcin 'Qrczak' Kowalczyk [email protected]
8 Feb 2001 20:28:13 GMT


Thu, 8 Feb 2001 21:41:56 +1100, Fergus Henderson <[email protected]> pisze:

> Should this define an instance for `foo T'?
> (I think not.)
> 
> How about if the instance declaration is changed to
> 
>         instance bar T where
> 		f = 41
> 		-- no definition for f2
> 		b = 42
> 
> ?
> (In that case, I think it should.)

I don't like the idea of treating the case "no explicit definitions
were given because all have default definitions which are OK"
differently than "some explicit definitions were given".

When there is a superclass, it must have an instance defined, so if
we permit such thing at all, I would let it implicitly define all
superclass instances not defined explicitly, or something like that.
At least when all methods have default definitions. Yes, I know that
they can be mutually recursive and thus all will be bottoms...

So maybe there should be a way to specify that default definitions
are cyclic and some of them must be defined? It is usually written
in comments anyway, because it is not immediately visible in the
definitions. If not formally in the language (now any method definition
can be omitted even if it has no default!), then perhaps the compiler
could detect most cases when methods are defined in terms of one
another and give a warning.

Generally the compiler could warn if the programmer has written bottom
in an unusual way. For example
    f x = g some_expression
    g x = f some_expression
is almost certainly a programmer error.

-- 
 __("<  Marcin Kowalczyk * [email protected] http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK