> I am writing code that would like to use the word "product" as a field
> selector for a Product (object representing something for sale).
> Unfortunately, it can't easily use "product" because the prelude claims
> the word for multiplication.  

seems like another reason to advocate ad hoc polymorphism
(allow a name to denote several things, as long as they have
different types). 

especially for Haskell records (datatypes with labelled fields),
when they were introduced, i thought, fine, this would make
programming easier, but the i found, no, since "field names
share the top level namespace" (report 4.2.1).

if i have two types Foo and Bar and both have a "product" field,
the only way out is to name this field "productFoo" and "productBar".
i'd rather write "product (x :: Foo)" instead.
and i don't even had to do that if the compiler would know x's type
from elsewhere.

i guess all of this is due to the fact that Haskell,
by design, wants to do full type reconstruction 
(given the bare program, the compiler infers all types) 
instead of type checking (types provided by the programmer).

i understand that functional programming languages 
are proud to be able to find all types
but is it useful software engineering?

i argue it's contraproductive. it's not the right target
(instead the programmer should be forced to declare types)
and hitting it introduces restricitions (see above).

all of this strictly IMHO, of course. but there is hope, as
http://research.microsoft.com/Users/simonpj/Haskell/std-haskell.html#deferred
contains "ad hoc overloading".

-- 
Dr. Johannes Waldmann     Institut fur Informatik    Universitat Leipzig
[EMAIL PROTECTED] http://www.informatik.uni-leipzig.de/~joe/
Augustusplatz, D-04109 Leipzig, Germany, Tel/Fax (+49) 341 97 32 204/209


Reply via email to