On Sat, 6 Jun 1998, Fergus Henderson wrote:

[...]
> But I think it would be nice to have better language support.
> 
[...]
> 
> I think you can go even ahead and declare OrganizationThing to be
> a member of class Organization:
> 
>       instance Organization OrganizationThing where
>               name (MkOrg o) = name o
>               foo (MkOrg o) = foo o
>               bar (MkOrg o) = bar o
>               -- similarly for all methods of class Organization
>       
> Then you don't need to use that annoying MkOrg constructor so often --
> in fact, you only need it when constructing values, I don't think
> you ever need it for deconstruction.
> 
> However, adding these instance declarations is a bit tedious.
> Wouldn't it be handy if the compiler could do that automatically?
> 
> So, why not also extend the language so that it if `Foo' is a type class,
> then `any Foo' is a type and `new Foo' is a constructor
> for that type, and the type `any Foo' is automatically made an
> instance of the class `Foo'?
> This would make object-oriented programming a lot more convenient.
> 
[...]

Yes, it would be rather convenient but the problem is that it will be
rather ad-hoc. I don't see how it fits with the constructor-classes. And
future versions of Haskell will probably have multi-parameter type-classes
and this will also cause problems for this mechanism (what type would 
'any Foo' refer to).

My opinion is that Haskell should be kept clean and orthogonal as I think
it is right now (with a few embarrasing exceptions like the default
mechanism for example) and this sort of thing will ruin that.

The argument that the above declaration is tedios is, I think, irrelevant.
First of all; ofcourse it would be nice if the compiler could generate
everything that is possible derive but that is not always a help. Consider
c++ were type-conversions can happen almost by magic and in situations
where one wanted the compiler to report an error (it has happend to me a
couple of times and is rather annoying). Secondly, talking about
functional programming as tedious is being very lazy. Compared to
objectoriented languages the definition above is not a big block of code.

To sum up; all typed languages have the problem that some thing cannot be
expressed easily because it is not typesafe. I think Haskell has very good
expressive power in this sense, due to its anvanced typesystem, and I
think that existential types are great as they are in hbc. Ofcourse one
could always ask more but it will always be a trade of, the typesystem is
already so complicated in Haskell most mortals don't understand it :-).

        /Josef

----------------------------------------------------------
|Josef Svenningsson|http://www.dtek.chalmers.se/~d95josef|
|Rubingatan 39     |  email: [EMAIL PROTECTED]   |
|421 62 G�teborg   |          tel: 031-7090774           |
----------------------------------------------------------
What is a magician but a practising theorist?
                -- Obi-Wan Kenobi




Reply via email to