[mercury-users] variable parameters in typeclass instances
Michael Day
mikeday at corplink.com.au
Thu Nov 11 22:20:40 AEDT 1999
> That is unfortunate, it seems like such declarations would be quite
> useful, even in the absence of constructor classes. I can't speculate on a
> revised implementation that could handle such declarations so I will
> assume they are not feasible.
Just a quick follow up to my previous message. As I think Ralph suggested,
equivalent functionality to this:
:- typeclass container(C, T) <= arbitrary_constraint(T) where
[
pred insert(T, C(T), C(T)),
mode insert(in, in, out) is det,
...
].
can simply be achieved by this:
:- typeclass container(C) where
[
pred insert(T, C(T), C(T)) <= arbitrary_constraint(T),
mode insert(in, in, out) is det,
...
].
(Assuming support for constructor classes of course). Adding the arbitrary
constraint to each predicate in the type class is a little dissatisfying
but hardly a bar to such usage. I'm still wondering what it *means* for
some of the predicates to have the constraint and some not, but it all
seems to work. I still think it would be nice to be able to specify
universal type class instances, but it could be that I'm just wrong...
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