Hi Alex,

>[...]
>[ describes that he wants interleave the definitions of several functions ]
>[ but Haskell does not allow this ]
>[...]
>This restriction is very frustrating because I want to add names to a
>function lookup table as they are derived.   Is there a strong reason for
>disallowing this syntax?

Well, it depends on what you call *strong*. The only reason that I heard is
that it prevents users from making possibly unwanted errors. The reasoning
behind this is that no sane programmer would write

  data Shape = Circle Float | Rectangle Float Float; area, perimeter ::
Shape -> Float

  area          (Circle r) = ...
  perimeter (Circle r) = ...

  area          (Rectangle w h) = ...
  perimeter (Rectangle w h) = ...

so if someone does it is probably a mistake. I think it sometimes makes
sense to sort definitions accoring to their argument pattern (the OO-style),
and sometimes according to their name (the FP-style). The compiler can sort
them as it wants later.

In my opinion a language should not be patronizing, it should not prevent me
from writing programs in what the language police thinks is bad style
(that's why unsafePerformIO is my big friend ;-).

For me this is particulary thorny because my idea of what is good style
tends to be very different from the mainstream. I used to be the lone voice
in the wilderness on this issue too, great to have a partisan!

>2. local import
>A module only needs to import a class definition if a type in the module
>derives that class.  It would be nice to have locally scoped import so
>that the user does not both have to add derive statements and have to add
>import statements (and deal with name space conflicts)

What do you mean? That if you write data Foo ..... deriving (Bar) you
automatically import the module in which the Bar class is defined? I think
what you want is import statements at arbitrary places in a module.
Something that was dropped from Haskell98.

Erik "warrior against gratuitous restrictions" Meijer



Reply via email to