Files
mercury/tests/valid/func_method.m
David Jeffery 6145542814 Add a test case for a function as a typeclass method.
Estimated hours taken: 0.1


tests/valid/typeclasses/func_method.m:
        Add a test case for a function as a typeclass method. The non-locals
        were not being set correctly, which caused a software error in this
        case.
tests/valid/typeclasses/Mmakefile:
        Turn this test on.
1998-07-29 06:28:17 +00:00

23 lines
493 B
Mathematica

%-----------------------------------------------------------------------------%
:- module func_method.
:- interface.
:- type pair(A, B) ---> pair(A, B).
:- typeclass c(A) where [
func op(pair(A, B)) = pair(A, B),
mode op(in) = out is det
].
:- instance c(int) where [
func(op/1) is op_int
].
:- implementation.
:- func op_int(pair(int, T)) = pair(int, T).
:- mode op_int(in) = out is det.
op_int(X) = X.
%-----------------------------------------------------------------------------%