On 05-May-2000, S.D.Mechveliani <[EMAIL PROTECTED]> wrote:
> Harmless for hackers, advanced for snobs
> ----------------------------------------
> I am going to prove (can I ?) that  basAlgPropos  is so. 
> The approach is: do not mention advanced features in the hacker 
> program, and the program would not bite you.
...
> Few explicit categories, many implicit ones
> -------------------------------------------
> AddSemigroup ... Ring, EuclideanRing ...  are the explicit 
> categories - there are provided the *classes* for them.
> 
> How the hacker uses them? One simply takes  (+) from Additive,
> (*) from  Multiplicative,  dimRem  from  EuclideanRing
> - instead of  Num, Integral  of old Haskell-98. 
> When one wants the instance for the type  T  with, say, (*), 
> one needs to declare for it  
>   instance Set T                       -- skip implementation !
>   instance Multiplicative T where (*) = ...

Personally I think it is bad that Haskell allows this.
The Haskell report says the following:

 | If no binding is given for some class method then the corresponding
 | default class method in the class declaration is used (if present);
 | if such a default does not exist then the class method of this
 | instance is bound to undefined and no compile-time error results.

But I think it would be better if the last two lines were replaced
with

 | 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.

> Also one writes, for example,                   zero x  
> instead of                                      zero `asTypeOf` x.

The latter is clearer.  This change reduces program readability, IMHO.
I also agree with Marcin 'Qrczak' Kowalczyk's arguments on this issue.

> Is simplicity possible?
> -----------------------
> Some people say here, that this is impossible, that the compilation
> errors become the run-time ones ...
> I do not see, so far, in what way these matters may occur serious.
> For the critics, it is a good point to provide some schematic 
> examples.

OK.  Consider the following scenario.  Alfred defines a type `T'
and writes such a vacuous instance declaration for `Set T'.
This is part of a large library package that Alfred has written.
Meanwhile, Betty has written another library package that provides functions
on `set a'.  Charles writes a program using both Alfred's and Betty's
libraries.  Being pressed for time (aren't we all?), Charles does not
test his program very thoroughly.  Instead, since his program
type-checks, and it's late Friday evening and already past the
deadline, he ships his program to Duncan.  On Monday morning, 
Charles is surprised to find an angry message from Duncan saying
that the program didn't work.  Of course, Duncan doesn't give Charles
enough information to duplicate the problem, so Charles wastes
most of Monday trying to get the appropriate information from
Duncan so that he can reproduce the bug.  Finally he does so,
and is able to reproduce the problem.  After a fair amount
of time debugging, he is able to track the problem down.

But he still can't solve it!  The problem is that in order
to solve it, he needs to modify Alfred's library package.
For a variety of reasons, doing that could be difficult.
Firstly, he might not have source code.  Secondly, even if
he did have source code, there may be copyright issues --
he might not have legal permission to modify it.
Thirdly, even if he did have source code, and permission to
modify it, it may be problematic to do so, since (a)
now he will have to ship Duncan the modified version of
the library, and (b) this may lead to maintenance difficulties
if Alfred later releases a new version of his library.

-- 
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