I think that this is a VERY good idea!
Each expression then has a set of possible types, and the ambiguity is
resolved by an explicit type signature.
At present it is quite frustrating in Haskell that when a name is used in
one place it is then lost for use in any other context -- the example of
an overloaded size function strikes me as very sound.
I would have no objection to having to declare more type annotation -- it
seems to me that too many of the restrictions on the design of Haskell's
type system are driven by the desire to infer too much without asking the
user for annotations.
I think it would be very interesting to re-visit the constraints on
multi-parameter classes and instances in the view that the compiler may
require type annotations on particular variables.
----------
From: joe
Sent: 08 July 1998 15:21
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: multi param type classes
From: Johannes Waldmann <[EMAIL PROTECTED]>
Subject: Re: multi param type classes
To: [EMAIL PROTECTED]
Ralf,
you want to lift this restriction:
> The type of each class operation
> must mention all of the class type variables.
how would you resolve ambiguities?
probably by requiring an explicit type signature
at the point of usage.
fine, but then i'd like to have this in other cases as well,
finally arriving at Ada-style overloading
(a name may have several meanings
as long as they can be distinguished by their type)
then i could write size :: [a] -> Int; size :: Tree a -> Int,
and the two things are completely unrelated.
at the moment, i could make [] and Tree an instance
of a class that has `size' as a method (feels clumsy)
or write sizeList and sizeTree (feels bad as well:
what is part of the name here is really a type signature).
of course this would break the general Haskell idea
that every expression has a unique type
that can be reconstructed by the compiler.
but this is broken anyway (you need type annotations here and there),
and is it a good design goal?
why would you want it? for easier compilation?
for easier programming? an Haskell where i'd have to declare
the type for some, or even each, let-bound variable
doesn't feel that horrendous to me. plenty of other languages
require typed declarations.
best regards,
--
Dr Johannes Waldmann Institut fur Informatik Universitat Leipzig
[EMAIL PROTECTED] http://www.informatik.uni-leipzig.de/~joe/
PF 920, D-04009 Leipzig, Germany Tel/Fax (+49) 341 97 32204 / 32209