[m-dev.] multiparameter type classes

David Overton dmo at cs.mu.OZ.AU
Thu Apr 4 11:40:10 AEST 2002


Hi,

I'm trying to work out a type class hierarchy for constraint solvers in
HAL.  The HAL compiler converts HAL classes directly into Mercury type
classes.

What we want to do it have a multi-parameter type class for representing
a base type - solver type pair something like:

	:- typeclass solver_for(B, S) where [ ... ].

which could have instances such as

	:- instance solver_for(float, clpr:cfloat).

So far, so good.  The problem arises where we want to have a predicate
which uses a solver for a specific type, e.g:

	:- pred foo(S) <= solver_for(float, S).

or even

	:- typeclass solver_for_float(S) <= solver_for(float, S) where [ ... ].
	:- pred foo(S) <= solver_for_float(S).

However, neither of these is allowed in the current Mercury
implementation;  prog_io does not allow the types in a constraint to be
anything other than variables.

Does anyone know the reason why this is not supported?  Are there
theoretical reasons or is it just a case of ``not yet implemented'' (as
the error message implies)?  If the latter, does anyone have any
indication of how much work would be involved to implement this?



David
-- 
David Overton      Computer Science and Software Engineering
PhD Student        The University of Melbourne   +61 3 8344 9159
Research Fellow    Monash University (Clayton)   +61 3 9905 5779
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list