[m-rev.] first step towards functional dependencies (1/3)

Mark Brown mark at cs.mu.OZ.AU
Wed Mar 23 23:34:54 AEDT 2005


On 23-Mar-2005, Mark Brown <mark at cs.mu.OZ.AU> wrote:
> The restriction is probably not that serious.  In fact, I'm only aware of
> one example that would need this feature.  I'll post a description of that
> separately, in case anyone is curious.

The example is from Mark P. Jones' ESOP 2000 paper.

(I'm making up concrete syntax for functional dependencies here.  Feel free
to chip in with alternatives.)

\begin{example code}

	% These two typeclasses should be obvious.

:- typeclass add(A, B, C) given [{A, B} >> C] where [
	func A + B = C
].

:- typeclass mul(A, B, C) given [{A, B} >> C] where [
	func A * B = C
].

	% Some example instances:

:- instance mul(int, int, int) where ...
:- instance mul(int, float, float) where ...
:- instance mul(float, int, float) where ...
:- instance mul(float, float, float) where ...

	% A type representing matrices:

:- type mat(T).

	% An instance for matrix multiplication, with two constraints.

:- instance mul(mat(A), mat(B), mat(D)) <= (mul(A, B, C), add(C, C, D)) ...

\end{example code}

The above should be type correct, but it would be rejected because the
intermediate value (with type C) doesn't appear in the head of the instance
declaration.

Cheers,
Mark.

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list