[m-dev.] for review: new mode syntax

Tyson Dowd trd at cs.mu.OZ.AU
Wed Aug 16 16:14:09 AEST 2000


On 16-Aug-2000, Tyson Richard DOWD <trd at cs.mu.OZ.AU> wrote:
> On 16-Sep-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > On 15-Aug-2000, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > > Make the syntax for defining modes and insts similar to type equivalence.
> > ...
> > > compiler/prog_io_util.m:
> > > 	Make `>>' the standard operator for inline mode declarations.
> > > 	`->' is still supported.
> > 
> > You should also change mercury_output_mode in mercury_to_mercury.m
> > so that it outputs modes using the new syntax.
> > 
> > Also it would be a good idea to change the mode definitions in
> > the Mercury library reference manual (i.e. in the interfaces of
> > the standard library module) to use the new syntax.
> > There's only three modules that define modes using the old
> > syntax, namely builtin.m, list.m, and tree234.m.  (The array.m
> > module also defines modes, but it already uses the "==" syntax.)
> 
> That will be fine, but I think bootstrapping this change is required
> before that will work (at least, changing -> to >> needs to be
> bootstrapped).
> 
> Changing mercury_to_mercury should wait too, otherwise I may end up
> causing transitional problems (if you are mixing compilers it could cause
> a problem).   It's just a little safer this way (less chance I have to
> fix bugs or listen to people complain about the transition!).

When committed, these changes will look something like what is below.

However for now I will not commit these changes.

Index: library//array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.72
diff -u -r1.72 array.m
--- library//array.m	2000/08/02 14:13:06	1.72
+++ library//array.m	2000/08/16 05:28:34
@@ -40,7 +40,7 @@
 
 :- type array(T).
 
-:- inst array(I) = bound(array(I)).
+:- inst array(I) == bound(array(I)).
 :- inst array == array(ground).
 :- inst array_skel == array(free).
 
@@ -48,7 +48,7 @@
 	% so to work-around that problem, we currently don't use
 	% unique modes in this module.
 
-% :- inst uniq_array(I) = unique(array(I)).
+% :- inst uniq_array(I) == unique(array(I)).
 % :- inst uniq_array == uniq_array(unique).
 :- inst uniq_array(I) = bound(array(I)). % XXX work-around
 :- inst uniq_array == uniq_array(ground). % XXX work-around
@@ -58,9 +58,9 @@
 :- mode array_uo == out(uniq_array).
 :- mode array_ui == in(uniq_array).
 
-% :- inst mostly_uniq_array(I) = mostly_unique(array(I)).
+% :- inst mostly_uniq_array(I) == mostly_unique(array(I)).
 % :- inst mostly_uniq_array == mostly_uniq_array(mostly_unique).
-:- inst mostly_uniq_array(I) = bound(array(I)).	% XXX work-around
+:- inst mostly_uniq_array(I) == bound(array(I)).	% XXX work-around
 :- inst mostly_uniq_array == mostly_uniq_array(ground).	% XXX work-around
 :- inst mostly_uniq_array_skel == mostly_uniq_array(free).
 
Index: library//builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.38
diff -u -r1.38 builtin.m
--- library//builtin.m	2000/08/02 14:13:07	1.38
+++ library//builtin.m	2000/08/16 05:25:18
@@ -45,8 +45,8 @@
 % The name `dead' is allowed as a synonym for `clobbered'.
 % Similarly `mostly_dead' is a synonym for `mostly_clobbered'.
 
-:- inst dead = clobbered.
-:- inst mostly_dead = mostly_clobbered.
+:- inst dead == clobbered.
+:- inst mostly_dead == mostly_clobbered.
 
 % The `any' inst used for the constraint solver interface is also builtin.
 
@@ -60,40 +60,40 @@
 
 % The standard modes.
 
-:- mode unused :: (free -> free).
-:- mode output :: (free -> ground).
-:- mode input :: (ground -> ground).
-
-:- mode in :: (ground -> ground).
-:- mode out :: (free -> ground).
-
-:- mode in(Inst) :: (Inst -> Inst).
-:- mode out(Inst) :: (free -> Inst).
-:- mode di(Inst) :: (Inst -> clobbered).
-:- mode mdi(Inst) :: (Inst -> mostly_clobbered).
+:- mode unused == (free >> free).
+:- mode output == (free >> ground).
+:- mode input == (ground >> ground).
+
+:- mode in == (ground >> ground).
+:- mode out == (free >> ground).
+
+:- mode in(Inst) == (Inst >> Inst).
+:- mode out(Inst) == (free >> Inst).
+:- mode di(Inst) == (Inst >> clobbered).
+:- mode mdi(Inst) == (Inst >> mostly_clobbered).
 
 % Unique modes.  These are still not fully implemented.
 
 % unique output
-:- mode uo :: free -> unique.
+:- mode uo == free >> unique.
 
 % unique input
-:- mode ui :: unique -> unique.
+:- mode ui == unique >> unique.
 
 % destructive input
-:- mode di :: unique -> clobbered.
+:- mode di == unique >> clobbered.
 
 % "Mostly" unique modes (unique except that that may be referenced
 % again on backtracking).
 
 % mostly unique output
-:- mode muo :: free -> mostly_unique.
+:- mode muo == free >> mostly_unique.
 
 % mostly unique input
-:- mode mui :: mostly_unique -> mostly_unique.
+:- mode mui == mostly_unique >> mostly_unique.
 
 % mostly destructive input
-:- mode mdi :: mostly_unique -> mostly_clobbered.
+:- mode mdi == mostly_unique >> mostly_clobbered.
 
 % Higher-order predicate modes are builtin.
 
Index: library//getopt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/getopt.m,v
retrieving revision 1.22
diff -u -r1.22 getopt.m
--- library//getopt.m	1999/10/30 04:15:59	1.22
+++ library//getopt.m	2000/08/16 05:27:44
@@ -128,7 +128,7 @@
 				maybe_option_table(OptionType))
 		).
 
-:- inst option_ops =
+:- inst option_ops ==
 	bound((
 		option_ops(
 			pred(in, out) is semidet,	% short_option
Index: library//list.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.92
diff -u -r1.92 list.m
--- library//list.m	2000/07/19 03:41:54	1.92
+++ library//list.m	2000/08/16 05:23:58
@@ -32,27 +32,27 @@
 	% Partially instantiated mode aren't fully implemented yet,
 	% so don't try to use these.
 
-:- inst list_skel(I) = bound(([] ; [I | list_skel(I)])).
-:- inst list_skel = list_skel(free).
+:- inst list_skel(I) == bound(([] ; [I | list_skel(I)])).
+:- inst list_skel == list_skel(free).
 
-:- inst non_empty_list = bound([ground | ground]).
+:- inst non_empty_list == bound([ground | ground]).
 
-:- mode in_list_skel :: list_skel -> list_skel.
-:- mode out_list_skel :: free -> list_skel.
-:- mode list_skel_out :: list_skel -> ground.
+:- mode in_list_skel == list_skel >> list_skel.
+:- mode out_list_skel == free >> list_skel.
+:- mode list_skel_out == list_skel >> ground.
 
 	% These more verbose versions are deprecated.
 	% They exist only for backwards compatibility,
 	% and will be removed in a future release.
-:- mode input_list_skel :: in_list_skel.
-:- mode output_list_skel :: out_list_skel.
-:- mode list_skel_output :: list_skel_out.
+:- mode input_list_skel == in_list_skel.
+:- mode output_list_skel == out_list_skel.
+:- mode list_skel_output == list_skel_out.
 
 	% These modes are particularly useful for passing around lists
 	% of higher order terms, since they have complicated insts
 	% which are not correctly approximated by "ground".
-:- mode list_skel_in(I) :: list_skel(I) -> list_skel(I).
-:- mode list_skel_out(I) :: free -> list_skel(I).
+:- mode list_skel_in(I) == list_skel(I) >> list_skel(I).
+:- mode list_skel_out(I) == free >> list_skel(I).
 
 %-----------------------------------------------------------------------------%
 
Index: library//tree234.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/tree234.m,v
retrieving revision 1.30
diff -u -r1.30 tree234.m
--- library//tree234.m	2000/07/24 00:52:34	1.30
+++ library//tree234.m	2000/08/16 05:26:19
@@ -127,7 +127,7 @@
 
 :- interface.
 
-:- inst uniq_tree234(K, V) =
+:- inst uniq_tree234(K, V) ==
 	unique((
 		empty
 	;	two(K, V, uniq_tree234(K, V), uniq_tree234(K, V))
@@ -137,7 +137,7 @@
 			uniq_tree234(K, V), uniq_tree234(K, V))
 	)).
 
-:- inst uniq_tree234_gg =
+:- inst uniq_tree234_gg ==
 	unique((
 		empty
 	;	two(ground, ground, uniq_tree234_gg, uniq_tree234_gg)
@@ -148,10 +148,10 @@
 			uniq_tree234_gg, uniq_tree234_gg)
 	)).
 
-:- mode di_tree234(K, V) :: uniq_tree234(K, V) -> dead.
-:- mode di_tree234       :: uniq_tree234(ground, ground) -> dead.
-:- mode uo_tree234(K, V) :: free -> uniq_tree234(K, V).
-:- mode uo_tree234       :: free -> uniq_tree234(ground, ground).
+:- mode di_tree234(K, V) == uniq_tree234(K, V) >> dead.
+:- mode di_tree234       == uniq_tree234(ground, ground) >> dead.
+:- mode uo_tree234(K, V) == free >> uniq_tree234(K, V).
+:- mode uo_tree234       == free >> uniq_tree234(ground, ground).
 
 :- implementation.
 
@@ -754,51 +754,51 @@
 %------------------------------------------------------------------------------%
 %------------------------------------------------------------------------------%
 
-:- inst two(K, V, T) =
+:- inst two(K, V, T) ==
 	bound(
 		two(K, V, T, T)
 	).
 
-:- inst uniq_two(K, V, T) =
+:- inst uniq_two(K, V, T) ==
 	unique(
 		two(K, V, T, T)
 	).
 
-:- inst three(K, V, T) =
+:- inst three(K, V, T) ==
 	bound(
 		three(K, V, K, V, T, T, T)
 	).
 
-:- inst uniq_three(K, V, T) =
+:- inst uniq_three(K, V, T) ==
 	unique(
 		three(K, V, K, V, T, T, T)
 	).
 
-:- inst four(K, V, T) =
+:- inst four(K, V, T) ==
 	bound(
 		four(K, V, K, V, K, V, T, T, T, T)
 	).
 
-:- inst uniq_four(K, V, T) =
+:- inst uniq_four(K, V, T) ==
 	unique(
 		four(K, V, K, V, K, V, T, T, T, T)
 	).
 
-:- mode uo_two :: out(uniq_two(unique, unique, unique)).
-:- mode suo_two :: out(uniq_two(ground, ground, uniq_tree234_gg)).
-:- mode out_two :: out(two(ground, ground, ground)).
-
-:- mode di_two :: di(uniq_two(unique, unique, unique)).
-:- mode sdi_two :: di(uniq_two(ground, ground, uniq_tree234_gg)).
-:- mode in_two :: in(two(ground, ground, ground)).
-
-:- mode di_three :: di(uniq_three(unique, unique, unique)).
-:- mode sdi_three :: di(uniq_three(ground, ground, uniq_tree234_gg)).
-:- mode in_three :: in(three(ground, ground, ground)).
-
-:- mode di_four :: di(uniq_four(unique, unique, unique)).
-:- mode sdi_four :: di(uniq_four(ground, ground, uniq_tree234_gg)).
-:- mode in_four :: in(four(ground, ground, ground)).
+:- mode uo_two  == out(uniq_two(unique, unique, unique)).
+:- mode suo_two == out(uniq_two(ground, ground, uniq_tree234_gg)).
+:- mode out_two == out(two(ground, ground, ground)).
+
+:- mode di_two  == di(uniq_two(unique, unique, unique)).
+:- mode sdi_two == di(uniq_two(ground, ground, uniq_tree234_gg)).
+:- mode in_two  == in(two(ground, ground, ground)).
+
+:- mode di_three  == di(uniq_three(unique, unique, unique)).
+:- mode sdi_three == di(uniq_three(ground, ground, uniq_tree234_gg)).
+:- mode in_three  == in(three(ground, ground, ground)).
+
+:- mode di_four  == di(uniq_four(unique, unique, unique)).
+:- mode sdi_four == di(uniq_four(ground, ground, uniq_tree234_gg)).
+:- mode in_four  == in(four(ground, ground, ground)).
 
 %------------------------------------------------------------------------------%
 
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.172
diff -u -r1.172 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m	2000/08/13 13:18:44	1.172
+++ compiler/mercury_to_mercury.m	2000/08/16 06:00:57
@@ -607,7 +607,7 @@
 	io__write_string(":- inst ("),
 	{ construct_qualified_term(Name, Args, Context, InstTerm) },
 	mercury_output_term(InstTerm, VarSet, no),
-	io__write_string(") = "),
+	io__write_string(") == "),
 	mercury_output_inst(Body, VarSet),
 	io__write_string(".\n").
 
@@ -1107,7 +1107,7 @@
 	io__write_string(":- mode ("),
 	{ construct_qualified_term(Name, Args, Context, ModeTerm) },
 	mercury_output_term(ModeTerm, VarSet, no),
-	io__write_string(") :: "),
+	io__write_string(") == "),
 	mercury_output_mode(Mode, VarSet),
 	io__write_string(".\n").
 
@@ -1150,7 +1150,7 @@
 	;
 	    io__write_string("("),
 	    mercury_output_inst(InstA, VarSet),
-	    io__write_string(" -> "),
+	    io__write_string(" >> "),
 	    mercury_output_inst(InstB, VarSet),
 	    io__write_string(")")
 	).

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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