Files
mercury/tests/valid/mode_syntax.m
Tyson Dowd 401298c013 Make the syntax for defining modes and insts similar to type equivalence.
Estimated hours taken: 2

Make the syntax for defining modes and insts similar to type equivalence.

Old syntax:
	:- inst foo = someinstdefn.
	:- mode foo :: someinst -> someotherinst.

New syntax:
	:- inst foo == someinstdefn.
	:- mode foo == someinst >> someotherinst.

The old syntax is still supported.  For `::' and `->' it may eventually
be phased out (but it doesn't cause many problems apart from possible
confusion of users, so it's a low priority).

In the case of `:- inst' we could already use `==' or `=', however we
now make `==' the standard syntax.  Again, we support both and probably
will for quite some time.

NEWS:
	Mention these changes.

compiler/prog_io.m:
	Make `==' the standard operator for `:- inst <InstDefn>.'
	declarations.

	Make `==' and `>>' the standard operators for
	`:- mode foo == someinst >> someotherinst'.
	`::' and `->' are still supported.

compiler/prog_io_util.m:
	Make `>>' the standard operator for inline mode declarations.
	`->' is still supported.

doc/reference_manual.texi:
	Update the syntax in the reference manual.
	Mention that `::' and `->' is deprecated.

tests/valid/Mmakefile:
tests/valid/mode_syntax.m:
	Add a new test of the new syntax.

compiler/fact_table.m:
	Fix a typo (missing quote) in the verbose messages for fact tables.
2000-09-15 11:25:02 +00:00

55 lines
928 B
Mathematica

%
% This is a test of the mode syntax.
%
% The official new syntax is:
%
% :- mode foo == bar >> baz.
%
% We also accept:
%
% :- mode foo :: bar -> baz.
%
% which is the old syntax.
%
% And finally we accept mixing them up:
%
% :- mode foo == (bar -> baz).
% :- mode foo :: bar >> baz.
%
% You can also use `bar >> baz' inline after a mode qualifier.
%
:- module mode_syntax.
:- interface.
:- import_module list.
:- mode my_input_list_skel == list_skel >> list_skel.
:- mode my_output_list_skel :: free >> list_skel.
:- mode my_list_skel_output == (list_skel -> ground).
:- mode another_mode :: list_skel -> list_skel.
:- pred p is semidet.
:- pred p2(list(T)::my_output_list_skel) is nondet.
:- implementation.
:- pred q(list(T)::list_skel >> list_skel /* my_input_list_skel */).
:- pred r(list(T)::my_output_list_skel).
q(_X) :- q([]).
r(X) :- r(X).
p :-
r(X),
q(X).
p2(X) :-
r(X),
q(X)
;
r(X),
q(X).