On 08-Jul-1998, Mariano Suarez Alvarez <[EMAIL PROTECTED]> wrote:
> On Wed, 8 Jul 1998 [EMAIL PROTECTED] wrote:
> 
> > 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 don't see why something like
> 
>       class HasSize a where
>         size :: a -> Int
> 
> doesn't solve this...

Well, for one thing, that only helps with functions, not with data
constructors.  Also, not every occurrence of `size' need have type
`a -> Int', and even if they do, the `class' declaration doesn't help
unless you modify the existing uses of the name `size', which you may
not be able to do.  The point is that you often have *unrelated*
occurrences of the same name.  This is especially true if you use
unqualified imports; two modules may use the same name for entirely
different purposes.  In that situation, Haskell forces you to resolve
the issue at module import time, even if the different uses of that
name could be disambiguated by the context, and in fact even if you
don't even make use of the overloaded name at all.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.


Reply via email to