[mercury-users] constructor class syntax
Michael Day
mikeday at corplink.com.au
Tue Nov 2 20:59:22 AEDT 1999
Hi,
making the assumption that Mercury will have support for constructor
classes in the not impossibly distant future, would it be reasonable to
expect syntax roughly like this:
:- class mappable(F(T)) where
[
pred map(pred(X, Y), F(A), F(B)),
mode map(in, in, out) is det
].
:- instance mappable(list(T)) where
[
pred(map/3) is list__map
].
I'm assuming here that type classes are merely a special case of
constructor classes and that both can be declared in a single unified
syntax. With that in mind it seems easier to combine :- typeclass and a
hypothetical :- constructorclass into :- class, and save typing all round.
It seems constraints on constructors as with normal type classes would be
useful, but what about constraints on constructor arguments?
:- class mappable(F(T)) <= container(F) where
[
pred map(pred(X, Y), F(A), F(B)),
mode map(in, in, out) is det
].
I can't see any use of expressing constraints on T, at this point. Would
it in fact be desirable to rephrase the declaration as:
:- class mappable(F/1) ...
or can useful constraints be placed on the constructor arguments? Can
current type class declarations be seen as having an implicit zero arity:
:- typeclass ordered(T/0) ...
given that they're listed in instance declarations with all arguments
specified (fully curried?).
Any words of wisedom regarding the future direction of Mercury classes
syntax would be appreciated.
Michael
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list