[m-rev.] diff: predmodes and state variables in browser

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Sep 2 14:00:26 AEST 2004


browser/dl.m:
browser/help.m:
browser/parse.m:
browser/util.m:
	Bring these modules up to date with our current coding guidelines:
	using predmode declarations and state variable syntax where relevant.

Zoltan.

cvs server: Diffing .
Index: dl.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/dl.m,v
retrieving revision 1.22
diff -u -b -r1.22 dl.m
--- dl.m	16 Jul 2004 08:08:29 -0000	1.22
+++ dl.m	2 Sep 2004 03:53:44 -0000
@@ -27,11 +27,11 @@
 
 % interface to the C function dlopen()
 :- pred dl__open(string::in, (mode)::in, scope::in, dl__result(handle)::out,
-	io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
 % low-level interface to the C function dlsym() -- returns a c_pointer.
 :- pred dl__sym(handle::in, string::in, dl__result(c_pointer)::out,
-	io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
 % high-level interface to the C function dlsym().
 % This version returns a higher-order predicate or function term.
@@ -51,7 +51,7 @@
 % or `char' is not supported.
 
 :- pred dl__mercury_sym(handle::in, mercury_proc::in, dl__result(T)::out,
-	io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
 % interface to the C function dlclose()
 %
@@ -75,8 +75,7 @@
 % (Note that using builtin__copy/2, to make copies rather than
 % keeping references, is *not* guaranteed to work in all cases.)
 % 
-:- pred dl__close(handle::in, dl__result::out,
-	io__state::di, io__state::uo) is det.
+:- pred dl__close(handle::in, dl__result::out, io::di, io::uo) is det.
 
 :- implementation.
 :- import_module std_util, require, string, list, int.
@@ -97,27 +96,29 @@
 :- pragma foreign_proc("C",
 	is_null(Pointer::in),
 	[will_not_call_mercury, promise_pure, thread_safe],
-"SUCCESS_INDICATOR = ((void *) Pointer == NULL)").
+"
+	SUCCESS_INDICATOR = ((void *) Pointer == NULL)
+").
+
 is_null(_) :-
 	private_builtin__sorry("dl__is_null").
 
-open(FileName, Mode, Scope, Result) -->
-	dlopen(FileName, Mode, Scope, Pointer),
-	( { is_null(Pointer) } ->
-		dlerror(ErrorMsg),
-		{ Result = error(ErrorMsg) }
+open(FileName, Mode, Scope, Result, !IO) :-
+	dlopen(FileName, Mode, Scope, Pointer, !IO),
+	( is_null(Pointer) ->
+		dlerror(ErrorMsg, !IO),
+		Result = error(ErrorMsg)
 	;
-		{ Result = ok(handle(Pointer)) }
+		Result = ok(handle(Pointer))
 	).
 
-/*
-** Note that dlopen() may call startup code (e.g. constructors for global
-** variables in C++) which may end up calling Mercury, so it's not safe
-** to declare this as `will_not_call_mercury'.
-*/
+% Note that dlopen() may call startup code (e.g. constructors for global
+% variables in C++) which may end up calling Mercury, so it's not safe
+% to declare this as `will_not_call_mercury'.
 
 :- pred dlopen(string::in, (mode)::in, scope::in, c_pointer::out,
-	io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
+
 :- pragma foreign_proc("C",
 	dlopen(FileName::in, Mode::in, Scope::in, Result::out,
 		_IO0::di, _IO::uo),
@@ -135,16 +136,17 @@
 	Result = (MR_Word) NULL;
 #endif
 }").
-dlopen(_, _, _, _) -->
-	{ private_builtin__sorry("dl__dlopen") }.
 
-mercury_sym(Handle, MercuryProc0, Result) -->
-	{ check_proc_spec_matches_result_type(Result, _,
-		MercuryProc0, MercuryProc1) },
-	{ check_type_is_supported(Result, _, MercuryProc1, MercuryProc) },
-	{ MangledName = proc_name_mangle(MercuryProc) },
-	sym(Handle, MangledName, Result0),
-	{
+dlopen(_, _, _, _, !IO) :-
+	private_builtin__sorry("dl__dlopen").
+
+mercury_sym(Handle, MercuryProc0, Result, !IO) :-
+	check_proc_spec_matches_result_type(Result, _,
+		MercuryProc0, MercuryProc1),
+	check_type_is_supported(Result, _, MercuryProc1, MercuryProc),
+	MangledName = proc_name_mangle(MercuryProc),
+	sym(Handle, MangledName, Result0, !IO),
+	(
 		Result0 = error(Msg),
 		Result = error(Msg)
 	;
@@ -152,7 +154,7 @@
 		private_builtin__unsafe_type_cast(make_closure(Address),
 			Closure),
 		Result = ok(Closure)
-	}.
+	).
 
 :- pragma foreign_decl("C",
 "
@@ -162,7 +164,6 @@
 	% Convert the given procedure address to a closure.
 :- func make_closure(c_pointer) = c_pointer.
 
-make_closure(_) = _ :- private_builtin__sorry("dl__make_closure").
 :- pragma foreign_proc("C", make_closure(ProcAddr::in) = (Closure::out),
 	[will_not_call_mercury, promise_pure],
 "{
@@ -171,6 +172,9 @@
 	MR_restore_transient_hp();
 }").
 
+make_closure(_) = _ :-
+	private_builtin__sorry("dl__make_closure").
+
 %
 % Check that the result type matches the information
 % in the procedure specification.
@@ -248,8 +252,10 @@
 % XXX this doesn't catch the case of no_tag types that
 % end up being equivalent to `float' or `char'.
 %
+
 :- pred check_type_is_supported(dl__result(T)::unused, T::unused,
 		mercury_proc::in, mercury_proc::out) is det.
+
 check_type_is_supported(_Result, Value, Proc0, Proc) :-
 	(
 		high_level_code,
@@ -263,7 +269,8 @@
 		),
 		type_ctor_module_name(ArgTypeCtor) = "builtin"
 	->
-		error("sorry, not implemented: dl__mercury_sym for procedure with argument type `float' or `char'")
+		error("sorry, not implemented: dl__mercury_sym " ++
+			"for procedure with argument type `float' or `char'")
 	;
 		high_level_code,
 		% The generic wrapper only works for procedures with up to
@@ -273,22 +280,24 @@
 		% so we can only support 18 other arguments.
 		type_ctor_arity(type_ctor(type_of(Value))) > 18
 	->
-		error("sorry, not implemented: dl__mercury_sym for procedure with more than 18 arguments")
+		error("sorry, not implemented: dl__mercury_sym " ++
+			"for procedure with more than 18 arguments")
 	;
 		Proc = Proc0
 	).
 
-sym(handle(Handle), Name, Result) -->
-	dlsym(Handle, Name, Pointer),
-	( { is_null(Pointer) } ->
-		dlerror(ErrorMsg),
-		{ Result = error(ErrorMsg) }
+sym(handle(Handle), Name, Result, !IO) :-
+	dlsym(Handle, Name, Pointer, !IO),
+	( is_null(Pointer) ->
+		dlerror(ErrorMsg, !IO),
+		Result = error(ErrorMsg)
 	;
-		{ Result = ok(Pointer) }
+		Result = ok(Pointer)
 	).
 
 :- pred dlsym(c_pointer::in, string::in, c_pointer::out,
-	io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
+
 :- pragma foreign_proc("C",
 	dlsym(Handle::in, Name::in, Pointer::out, _IO0::di, _IO::uo),
 	[will_not_call_mercury, promise_pure, tabled_for_io],
@@ -299,14 +308,16 @@
 	Pointer = (MR_Word) NULL;
 #endif
 }").
-dlsym(_, _, _) -->
-	{ private_builtin__sorry("dl__dlsym") }.
 
-:- pred dlerror(string::out, io__state::di, io__state::uo) is det.
+dlsym(_, _, _, !IO) :-
+	private_builtin__sorry("dl__dlsym").
+
+:- pred dlerror(string::out, io::di, io::uo) is det.
+
 :- pragma foreign_proc("C",
 	dlerror(ErrorMsg::out, _IO0::di, _IO::uo),
-	[will_not_call_mercury, promise_pure, tabled_for_io], "
-{
+	[will_not_call_mercury, promise_pure, tabled_for_io],
+"{
 	const char *msg;
 
 #if defined(MR_HAVE_DLFCN_H) && defined(MR_HAVE_DLERROR)
@@ -319,20 +330,21 @@
 
 	MR_make_aligned_string_copy(ErrorMsg, msg);
 }").
-dlerror(_) -->
-	{ private_builtin__sorry("dl__dlerror") }.
 
-close(handle(Handle), Result) -->
-	dlclose(Handle), 
-	dlerror(ErrorMsg),
-	{ Result = (if ErrorMsg = "" then ok else error(ErrorMsg)) }.
-
-/*
-** Note that dlclose() may call finalization code (e.g. destructors for global
-** variables in C++) which may end up calling Mercury, so it's not safe
-** to declare this as `will_not_call_mercury'.
-*/
-:- pred dlclose(c_pointer::in, io__state::di, io__state::uo) is det.
+dlerror(_, !IO) :-
+	private_builtin__sorry("dl__dlerror").
+
+close(handle(Handle), Result, !IO) :-
+	dlclose(Handle, !IO),
+	dlerror(ErrorMsg, !IO),
+	Result = (if ErrorMsg = "" then ok else error(ErrorMsg)).
+
+% Note that dlclose() may call finalization code (e.g. destructors for global
+% variables in C++) which may end up calling Mercury, so it's not safe
+% to declare this as `will_not_call_mercury'.
+
+:- pred dlclose(c_pointer::in, io::di, io::uo) is det.
+
 :- pragma foreign_proc("C",
 	dlclose(Handle::in, _IO0::di, _IO::uo),
 	[may_call_mercury, promise_pure, tabled_for_io],
@@ -341,8 +353,8 @@
 	dlclose((void *) Handle);
 #endif
 ").
-dlclose(_) -->
-	{ private_builtin__sorry("dl__dlclose") }.
+dlclose(_, !IO) :-
+	private_builtin__sorry("dl__dlclose").
 
 %-----------------------------------------------------------------------------%
 
@@ -357,6 +369,7 @@
 	SUCCESS_INDICATOR = MR_FALSE;
 #endif
 ").
+
 high_level_code :-
 	private_builtin__sorry("dl__high_level_code").
 
Index: help.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/help.m,v
retrieving revision 1.4
diff -u -b -r1.4 help.m
--- help.m	26 May 2003 08:59:44 -0000	1.4
+++ help.m	2 Sep 2004 03:53:44 -0000
@@ -46,17 +46,17 @@
 	% Print the top-level help nodes. This should give an overview
 	% of the main topics for which help is available.
 :- pred help__help(help__system::in, io__output_stream::in,
-	io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
 	% Print the help node at the given path. If there is none,
 	% print the top-level nodes.
 :- pred help__path(help__system::in, help__path::in, io__output_stream::in,
-	help__res::out, io__state::di, io__state::uo) is det.
+	help__res::out, io::di, io::uo) is det.
 
 	% Print all help nodes with the given name. If there are none,
 	% print the top-level nodes.
 :- pred help__name(help__system::in, string::in, io__output_stream::in,
-	io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
 %-----------------------------------------------------------------------------%
 
@@ -165,82 +165,81 @@
 
 %-----------------------------------------------------------------------------%
 
-help__help(Sys, Stream) -->
-	help__print_entry_list(Sys, Stream).
+help__help(Sys, Stream, !IO) :-
+	help__print_entry_list(Sys, Stream, !IO).
 
-help__name(Sys, Name, Stream) -->
-	help__search_entry_list(Sys, Name, 0, Count, Stream),
-	( { Count = 0 } ->
-		io__write_string("There is no such help topic.\n"),
-		help__help(Sys, Stream)
+help__name(Sys, Name, Stream, !IO) :-
+	help__search_entry_list(Sys, Name, 0, Count, Stream, !IO),
+	( Count = 0 ->
+		io__write_string("There is no such help topic.\n", !IO),
+		help__help(Sys, Stream, !IO)
 	;
-		[]
+		true
 	).
 
 :- pred help__search_entry_list(list(help__entry)::in, string::in,
-	int::in, int::out, io__output_stream::in,
-	io__state::di, io__state::uo) is det.
+	int::in, int::out, io__output_stream::in, io::di, io::uo) is det.
 
-help__search_entry_list([], _, C, C, _) --> [].
-help__search_entry_list([Entry | Tail], Name, C0, C, Stream) -->
-	{ Entry = entry(_, EntryName, Node) },
-	( { Name = EntryName } ->
+help__search_entry_list([], _, !C, _, !IO).
+help__search_entry_list([Entry | Tail], Name, !C, Stream, !IO) :-
+	Entry = entry(_, EntryName, Node),
+	( Name = EntryName ->
 		% We print this node, but don't search its children.
-		help__print_node(Node, Stream),
-		{ C = C0 + 1 }
+		help__print_node(Node, Stream, !IO),
+		!:C = !.C + 1
 	;
-		help__search_node(Node, Name, C0, C1, Stream),
-		help__search_entry_list(Tail, Name, C1, C, Stream)
+		help__search_node(Node, Name, !C, Stream, !IO),
+		help__search_entry_list(Tail, Name, !C, Stream, !IO)
 	).
 
 :- pred help__search_node(help__node::in, string::in, int::in, int::out,
-	io__output_stream::in, io__state::di, io__state::uo) is det.
+	io__output_stream::in, io::di, io::uo) is det.
 
-help__search_node(node(_, SubNodes), Name, C0, C, Stream) -->
-	help__search_entry_list(SubNodes, Name, C0, C, Stream).
+help__search_node(node(_, SubNodes), Name, !C, Stream, !IO) :-
+	help__search_entry_list(SubNodes, Name, !C, Stream, !IO).
 
-help__path(Entries, Path, Stream, Result) -->
-	( { Path = [Step] } ->
-		( { help__one_path_step(Entries, Step, Entry) } ->
-			{ Entry = entry(_, _, EntryNode) },
-			{ EntryNode = node(Text, _) },
-			io__write_string(Stream, Text),
-			{ Result = help__ok }
-		;
-			{ string__append_list(["error at path component """,
-				Step, """"], Msg) },
-			{ Result = help__error(Msg) }
+help__path(Entries, Path, Stream, Result, !IO) :-
+	(
+		Path = [Step | Tail],
+		( help__one_path_step(Entries, Step, Entry) ->
+			Entry = entry(_, _, EntryNode),
+			(
+				Tail = [],
+				EntryNode = node(Text, _),
+				io__write_string(Stream, Text, !IO),
+				Result = help__ok
+			;
+				Tail = [_ | _],
+				EntryNode = node(_, SubEntries),
+				help__path(SubEntries, Tail, Stream, Result,
+					!IO)
 		)
-	; { Path = [Step | Tail] } ->
-		( { help__one_path_step(Entries, Step, Entry) } ->
-			{ Entry = entry(_, _, EntryNode) },
-			{ EntryNode = node(_, SubEntries) },
-			help__path(SubEntries, Tail, Stream, Result)
-		;
-			{ string__append_list(["error at path component """,
-				Step, """"], Msg) },
-			{ Result = help__error(Msg) }
+		;
+			string__append_list(["error at path component """,
+				Step, """"], Msg),
+			Result = help__error(Msg)
 		)
 	;
-		{ Result = help__error("the path does not go that deep") }
+		Path = [],
+		Result = help__error("the path does not go that deep")
 	).
 
 %-----------------------------------------------------------------------------%
 
 :- pred help__print_entry_list(list(help__entry)::in, io__output_stream::in,
-	io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
-help__print_entry_list([], _) --> [].
-help__print_entry_list([entry(_, _, Node) | Nodes], Stream) -->
-	help__print_node(Node, Stream),
-	help__print_entry_list(Nodes, Stream).
+help__print_entry_list([], _, !IO).
+help__print_entry_list([entry(_, _, Node) | Nodes], Stream, !IO) :-
+	help__print_node(Node, Stream, !IO),
+	help__print_entry_list(Nodes, Stream, !IO).
 
 :- pred help__print_node(help__node::in, io__output_stream::in,
-	io__state::di, io__state::uo) is det.
+	io::di, io::uo) is det.
 
-help__print_node(node(Text, _Nodes), Stream) -->
-	io__write_string(Stream, Text).
-	% XXX help__print_entry_list(Nodes, Stream).
+help__print_node(node(Text, _Nodes), Stream, !IO) :-
+	io__write_string(Stream, Text, !IO).
+	% XXX help__print_entry_list(Nodes, Stream, !IO).
 
 %-----------------------------------------------------------------------------%
 
Index: parse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/parse.m,v
retrieving revision 1.18
diff -u -b -r1.18 parse.m
--- parse.m	27 Oct 2003 06:24:43 -0000	1.18
+++ parse.m	2 Sep 2004 03:53:44 -0000
@@ -151,11 +151,9 @@
 :- type external_request
 	---> external_request(string).
 
-:- pred parse__read_command(string, command, io__state, io__state).
-:- mode parse__read_command(in, out, di, uo) is det.
+:- pred parse__read_command(string::in, command::out, io::di, io::uo) is det.
 
-:- pred parse__read_command_external(command, io__state, io__state).
-:- mode parse__read_command_external(out, di, uo) is det.
+:- pred parse__read_command_external(command::out, io::di, io::uo) is det.
 
 %---------------------------------------------------------------------------%
 
@@ -176,32 +174,34 @@
 	;	name(string)
 	;	unknown(char).
 
-parse__read_command(Prompt, Command) -->
-	util__trace_get_command(Prompt, Line),
-	{ string__words(char__is_whitespace, Line) = Words },
-	( { parse(Words, Command2) } ->
-		{ Command = Command2 }
+parse__read_command(Prompt, Command, !IO) :-
+	util__trace_get_command(Prompt, Line, !IO),
+	string__words(char__is_whitespace, Line) = Words,
+	( parse(Words, Command2) ->
+		Command = Command2
 	;
-		{ Command = unknown }
+		Command = unknown
 	).
 
-parse__read_command_external(Command) -->
-	io__read(Result),
-	( { Result = ok(external_request(StringToParse)) } ->
-		{ string__words(char__is_whitespace, StringToParse) = Words },
-		( { parse(Words, Command2) } ->
-			{ Command = Command2 }
+parse__read_command_external(Command, !IO) :-
+	io__read(Result, !IO),
+	(
+		Result = ok(external_request(StringToParse)),
+		string__words(char__is_whitespace, StringToParse) = Words,
+		( parse(Words, Command2) ->
+			Command = Command2
 		;
-			{ Command = unknown }
+			Command = unknown
 		)
-	; { Result = eof } ->
-		{ Command = quit }
 	;
-		{ Command = unknown }
+		Result = eof,
+		Command = quit
+	;
+		Result = error(_, _),
+		Command = unknown
 	).
 
-:- pred lexer_words(list(string), list(token)).
-:- mode lexer_words(in, out) is det.
+:- pred lexer_words(list(string)::in, list(token)::out) is det.
 
 lexer_words([], []).
 lexer_words([Word | Words], Tokens) :-
@@ -209,15 +209,13 @@
 	lexer_words(Words, WordsTokens),
 	list__append(WordTokens, WordsTokens, Tokens).
 
-:- pred lexer_word(string, list(token)).
-:- mode lexer_word(in, out) is det.
+:- pred lexer_word(string::in, list(token)::out) is det.
 
 lexer_word(Word, Tokens) :-
 	string__to_char_list(Word, Chars),
 	lexer_word_chars(Chars, Tokens).
 
-:- pred lexer_word_chars(list(char), list(token)).
-:- mode lexer_word_chars(in, out) is det.
+:- pred lexer_word_chars(list(char)::in, list(token)::out) is det.
 
 lexer_word_chars([], []).
 lexer_word_chars([C | Cs], Toks) :-
@@ -247,8 +245,7 @@
 		lexer_word_chars(Cs, Toks2)
 	).
 
-:- pred lexer_dots(list(char), list(token)).
-:- mode lexer_dots(in, out) is det.
+:- pred lexer_dots(list(char)::in, list(token)::out) is det.
 
 lexer_dots([], []).
 lexer_dots([C | Cs], Toks) :-
@@ -262,16 +259,14 @@
 		Toks = [Tok | Toks2]
 	).
 
-:- pred dig_to_int(char, int).
-:- mode dig_to_int(in, out) is det.
+:- pred dig_to_int(char::in, int::out) is det.
 
 dig_to_int(C, N) :-
 	char__to_int('0', Zero),
 	char__to_int(C, CN),
 	N = CN - Zero.
 
-:- pred lexer_num(int, list(char), list(token)).
-:- mode lexer_num(in, in, out) is det.
+:- pred lexer_num(int::in, list(char)::in, list(token)::out) is det.
 
 lexer_num(N, Cs, Toks) :-
 	list__takewhile(char__is_digit, Cs, Digits, Rest),
@@ -279,8 +274,7 @@
 	Toks = [num(Num) | Toks2],
 	lexer_word_chars(Rest, Toks2).
 
-:- pred digits_to_int_acc(int, list(char), int).
-:- mode digits_to_int_acc(in, in, out) is det.
+:- pred digits_to_int_acc(int::in, list(char)::in, int::out) is det.
 
 digits_to_int_acc(Acc, [], Acc).
 digits_to_int_acc(Acc, [C | Cs], Num) :-
@@ -288,8 +282,7 @@
 	Acc2 = 10 * Acc + D,
 	digits_to_int_acc(Acc2, Cs, Num).
 
-:- pred lexer_name(char, list(char), list(token)).
-:- mode lexer_name(in, in, out) is det.
+:- pred lexer_name(char::in, list(char)::in, list(token)::out) is det.
 
 lexer_name(C, Cs, Toks) :-
 	list__takewhile(char__is_alnum_or_underscore, Cs, Letters, Rest),
@@ -299,8 +292,7 @@
 
 %---------------------------------------------------------------------------%
 
-:- pred parse(list(string), command).
-:- mode parse(in, out) is semidet.
+:- pred parse(list(string)::in, command::out) is semidet.
 
 parse(Words, Command) :-
 	(
@@ -443,8 +435,7 @@
 		fail
 	).
 
-:- pred parse_path(list(token), path).
-:- mode parse_path(in, out) is semidet.
+:- pred parse_path(list(token)::in, path::out) is semidet.
 
 	% SICStus is forgiving in the syntax of paths, hence so are we.
 	% XXX: Be less forgiving?
@@ -457,8 +448,7 @@
 		parse_dirs([Token | Tokens], Dirs)
 	).
 
-:- pred parse_dirs(list(token), list(dir)).
-:- mode parse_dirs(in, out) is semidet.
+:- pred parse_dirs(list(token)::in, list(dir)::out) is semidet.
 
 parse_dirs([], []).
 parse_dirs([Token | Tokens], Dirs) :-
@@ -485,8 +475,7 @@
 		parse_dirs(Tokens, Dirs)
 	).
 
-:- pred parse_setting(list(token), setting).
-:- mode parse_setting(in, out) is semidet.
+:- pred parse_setting(list(token)::in, setting::out) is semidet.
 
 parse_setting([Token | Tokens], Setting) :-
 	( Token = name("depth") ->
@@ -600,8 +589,7 @@
 
 % The commented out code is not currently used.
 
-% :- pred show_command(command, io__state, io__state).
-% :- mode show_command(in, di, uo) is det.
+% :- pred show_command(command::in, io::di, io::uo) is det.
 % 
 % show_command(ls(Path)) -->
 % 	io__write_string("ls "),
@@ -644,8 +632,7 @@
 % show_command(unknown) -->
 % 	io__write_string("unknown\n").
 % 
-% :- pred show_path(path, io__state, io__state).
-% :- mode show_path(in, di, uo) is det.
+% :- pred show_path(path::in, io::di, io::uo) is det.
 % 
 % show_path(root_rel(Dirs)) -->
 % 	io__write_string("/"),
@@ -653,8 +640,7 @@
 % show_path(dot_rel(Dirs)) -->
 % 	show_dirs(Dirs).
 % 
-% :- pred show_dirs(list(dir), io__state, io__state).
-% :- mode show_dirs(in, di, uo) is det.
+% :- pred show_dirs(list(dir)::in, io::di, io::uo) is det.
 % 
 % show_dirs([]) -->
 % 	io__nl.
@@ -670,8 +656,7 @@
 % 	io__write_string("../"),
 % 	show_dirs(Dirs).
 % 
-% :- pred show_setting(setting, io__state, io__state).
-% :- mode show_setting(in, di, uo) is det.
+% :- pred show_setting(setting::in, io::di, io::uo) is det.
 % 
 % show_setting(depth(Depth)) -->
 % 	io__write_string("depth "),
@@ -698,8 +683,7 @@
 % 	io__write_int(N),
 % 	io__nl.
 % 
-% :- pred show_format(portray_format, io__state, io__state).
-% :- mode show_format(in, di, uo) is det.
+% :- pred show_format(portray_format::in, io::di, io::uo) is det.
 % 
 % show_format(flat) -->
 % 	io__write_string("flat").
Index: util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/util.m,v
retrieving revision 1.23
diff -u -b -r1.23 util.m
--- util.m	16 Jul 2004 08:08:29 -0000	1.23
+++ util.m	2 Sep 2004 03:53:44 -0000
@@ -92,18 +92,18 @@
 util__is_function(predicate) = no.
 util__is_function(function) = yes.
 
-util__trace_getline(Prompt, Result) -->
-	io__input_stream(MdbIn),
-	io__output_stream(MdbOut),
-	util__trace_getline(Prompt, Result, MdbIn, MdbOut).
-
-util__trace_getline(Prompt, Result, MdbIn, MdbOut) -->
-	call_trace_getline(MdbIn, MdbOut, Prompt, Line, Success),
-	{ Success \= 0 ->
+util__trace_getline(Prompt, Result, !IO) :-
+	io__input_stream(MdbIn, !IO),
+	io__output_stream(MdbOut, !IO),
+	util__trace_getline(Prompt, Result, MdbIn, MdbOut, !IO).
+
+util__trace_getline(Prompt, Result, MdbIn, MdbOut, !IO) :-
+	call_trace_getline(MdbIn, MdbOut, Prompt, Line, Success, !IO),
+	( Success \= 0 ->
 		Result = ok(Line)
 	;
 		Result = eof
-	}.
+	).
 
 :- pred call_trace_getline(input_stream::in, output_stream::in, string::in,
 	string::out, int::out, io__state::di, io__state::uo) is det.
@@ -149,13 +149,13 @@
 	IO = IO0;
 ").
 
-call_trace_getline(_, _, _, _, _) -->
-	{ private_builtin__sorry("mdb__util__call_trace_getline") }.
+call_trace_getline(_, _, _, _, _, !IO) :-
+	private_builtin__sorry("mdb__util__call_trace_getline").
 
-util__trace_get_command(Prompt, Result) -->
-	io__input_stream(MdbIn),
-	io__output_stream(MdbOut),
-	util__trace_get_command(Prompt, Result, MdbIn, MdbOut).
+util__trace_get_command(Prompt, Result, !IO) :-
+	io__input_stream(MdbIn, !IO),
+	io__output_stream(MdbOut, !IO),
+	util__trace_get_command(Prompt, Result, MdbIn, MdbOut, !IO).
 
 :- pragma foreign_proc("C",
 	util__trace_get_command(Prompt::in, Line::out, MdbIn::in,
@@ -181,8 +181,8 @@
 	State = State0;
 ").
 
-util__trace_get_command(_, _, _, _) -->
-	{ private_builtin__sorry("mdb__util__trace_get_command/6") }.
+util__trace_get_command(_, _, _, _, !IO) :-
+	private_builtin__sorry("mdb__util__trace_get_command/6").
 
 util__zip_with(Pred, XXs, YYs, Zipped) :-
 	( (XXs = [], YYs = []) ->
--------------------------------------------------------------------------
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