[m-dev.] for review: allow clauses in instance declarations

David Glen JEFFERY dgj at students.cs.mu.oz.au
Fri Sep 8 12:55:45 AEDT 2000


On 07-Sep-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > XXX The new feature is not yet documented.
> 
> Estimated hours taken: 0.5
> 
> doc/reference_manual.texi:
> 	Document the new feature.

Looks great. Just one question:

> +Here's an example of an instance declaration and the different kinds
> +of method definitions that it can contain:
> +
> + at example
> +:- typeclass foo(T) where [
> +	func method1(T, T) = int,
> +	func method2(T) = int,
> +	pred method3(T::in, int::out) is det
> +	pred method4(T::in, io__state::di, io__state::uo) is det
> +].
> +
> +:- instance foo(int) where [
> +	% method defined by naming the implementation
> +	func(method1/1) is (+),
> +
> +	% method defined by a fact
> +	method2(X) = X + 1,

The brackets are deliberately left off here?

> +
> +	% method defined by a rule
> +	(method3(X, Y) :- Y = X + 2),
> +
> +	% method defined by a DCG rule
> +	(method4(X) --> io__print(X), io__nl)
> +].
> + at end example
> +	


dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) | If your thesis is utterly vacuous
PhD student,                    | Use first-order predicate calculus.
Dept. of Comp. Sci. & Soft. Eng.|     With sufficient formality
The University of Melbourne     |     The sheerist banality
Australia                       | Will be hailed by the critics: "Miraculous!"
                                |     -- Anon.
--------------------------------------------------------------------------
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