[clean-list] ADTs for fields in record types, please!

Robin Green greenrd@greenrd.org
Sat, 11 Oct 2003 18:36:39 +0100


One important thing that I find lacking in Clean 2.0, and which
I hope will be addressed in a future release, is proper support
for Abstract Data Types (ADTs) (aka interfaces in Java).

It should be possible, in *any* context where a type needs to be
specified, to specify by some means an Abstract Data Type, so
that one or more functions is defined on this abstract type,
but the actual implementation of the type (in terms of how it
is represented and how the function(s) is/are implemented)
can be freely varied on an instance-by-instance basis. "Freely"
in the sense that the postcondition(s) of the function(s)
should be adhered to, but the choice of representation should
be entirely open.

The best way to do that in Clean 2.0 seems to be to say
something like

myfunction::a -> Foo | ADT a

But it is not possible to use the "| ADT a" syntax when
defining the type of a field in a record type definition,
for example.

I have had to plump for a particular implementation of the 
ADT when declaring record types, which is an undesirable hack.
It reduces the freedom to use more efficient implementations
depending on the context.

Will this be fixed in a future release? Or is there some
alternative way of doing what I want to do that I've missed?
-- 
Robin