[m-rev.] for review: io__foldl

Simon Taylor stayl at cs.mu.OZ.AU
Wed Jan 23 01:23:18 AEDT 2002


On 21-Jan-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 15-Jan-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> 
> > --- tests/general/io_regression.m       11 Sep 2000 04:28:22 -0000      1.1
> 
> That should be mentioned in the CVS log message too.
> 
> There are also several files in the `extras' distribution that
> probably need to be modified:
> 
> 	extras/morphine/source/coverage_util.m
> 	extras/xml/tryit.m
> 	extras/xml/xml.parse.m

Done.

> > +++ library/io.m	15 Jan 2002 08:09:09 -0000
> > @@ -69,6 +69,12 @@
> >  :- type io__res(T)	--->	ok(T)
> >  			;	error(io__error).
> >  
> > +	% io__maybe_partial_res is used where it is possible to return
> > +	% a partial result when an error occurs,
> 
> s/,/./

Fixed.

Simon.


Estimated hours taken: 1

NEWS:
library/io.m:
	Add `io__input_stream_foldl', `io__input_stream_foldl_io'
	and `io__input_stream_foldl2_io', which apply a predicate
	to each character of an input stream in turn.

	Add a new result type `io__maybe_partial_res' which is
	used for operations which can return a partial result
	like io__input_stream_foldl* and io__read_file.

tests/general/io_regression.m:
extras/xml/xml.cat.m:
extras/xml/xml.parse.m:
extras/xml/tryit.m:
extras/morphine/source/coverage_util.m:
	Fix uses of io__read_file and io__read_file_as_string.

tests/general/Mmakefile:
tests/general/io_foldl.{m,exp}:
	Test case.
	

Index: extras/morphine/source/coverage_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/morphine/source/coverage_util.m,v
retrieving revision 1.1
diff -u -u -r1.1 coverage_util.m
--- extras/morphine/source/coverage_util.m	29 Aug 2001 12:17:19 -0000	1.1
+++ extras/morphine/source/coverage_util.m	22 Jan 2002 13:24:05 -0000
@@ -291,10 +291,15 @@
 		print("_cov.in'\n"),
 		io__seen
 	;
+	    io__read_file_as_string(BeginningResult),
+	    (
+		{ BeginningResult = error(_, Msg3) },
+		print(Msg3)
+	    ;
+		{ BeginningResult = ok(Beginning) },
 		print("% File automatically generated by get_"),
 	        print(CovType),
 		print(".m\n\n"),
-		io__read_file_as_string(_, Beginning),
 		print(Beginning),
 		print("initialize(Acc) :- \n\t list__condense(["),
 		% I do not generate the list of call site in the first place
@@ -307,13 +312,14 @@
 		print("], Acc)."),
 		io__told,
 		io__seen
-		),
+	    )
+	),
 	{ append_list([FileName2, "__", CovType], FileName4) },
 	io__tell(FileName4, Res3),
 	( 
-		{ Res3 = error(Msg3) }
+		{ Res3 = error(Msg4) }
 	->
-		print(Msg3)
+		print(Msg4)
 	;
 		print(CritList), 
 		print(".\n"),
Index: extras/xml/tryit.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/xml/tryit.m,v
retrieving revision 1.3
diff -u -u -r1.3 tryit.m
--- extras/xml/tryit.m	5 Jan 2001 04:15:44 -0000	1.3
+++ extras/xml/tryit.m	22 Jan 2002 13:24:42 -0000
@@ -31,7 +31,14 @@
 main([File|Files]) -->
     see(File, Res0),		
     ( { Res0 = ok } ->
-	    io__read_file_as_string(_, Text),
+	io__read_file_as_string(TextResult),
+	(
+	    { TextResult = error(_, TextErr) },
+	    stderr_stream(StdErr0),
+	    format(StdErr0, "error reading file `%s': %s\n",
+	    	[s(File), s(io__error_message(TextErr))])
+	;
+    	    { TextResult = ok(Text) },
 	    pstate(mkEntity(Text), mkEncoding(utf8), init),
 	    io((pred(Dirs0::out, di, uo) is det -->
 		get_environment_var("XML_DIRS", MStr),
@@ -84,6 +91,7 @@
 	    ),
 	    nl,
 	    []
+        )
     ;
 	[]
     ),
Index: extras/xml/xml.cat.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/xml/xml.cat.m,v
retrieving revision 1.1
diff -u -u -r1.1 xml.cat.m
--- extras/xml/xml.cat.m	5 Sep 2000 22:33:58 -0000	1.1
+++ extras/xml/xml.cat.m	22 Jan 2002 13:24:42 -0000
@@ -62,12 +62,9 @@
 		format(StdErr, "%s: %s\n", [s(Path), s(Msg)])
 	    ), Errors)
 	;
-	    { Res1 = error(Err) },
+	    { Res1 = error(_, Err) },
 	    { io__error_message(Err, Msg) },
 	    { Res = error(Msg) }
-	;
-	    { Res1 = eof },
-	    { Res = error("empty catalog file") }
 	)
     ;
         { Res0 = error(Msg) },
Index: extras/xml/xml.parse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/xml/xml.parse.m,v
retrieving revision 1.1
diff -u -u -r1.1 xml.parse.m
--- extras/xml/xml.parse.m	5 Sep 2000 22:34:00 -0000	1.1
+++ extras/xml/xml.parse.m	22 Jan 2002 13:24:42 -0000
@@ -3684,15 +3684,15 @@
     io(find(SystemId, Dirs), Res0),
     (
         { Res0 = ok(_Path) },
-	io((pred((Res10, Entity0)::out, di, uo) is det -->
-	    read_file_as_string(Res10, Entity0)
-	), (Res1, Entity)),
+	io((pred(Res10::out, di, uo) is det -->
+	    read_file_as_string(Res10)
+	), Res1),
 	(
-	    { Res1 = ok },
+	    { Res1 = ok(Entity) },
 	    io(seen),
 	    return(Entity)
 	;
-	    { Res1 = error(Err) },
+	    { Res1 = error(_, Err) },
 	    { io__error_message(Err, Msg) },
 	    error(Msg)
 	)
--------------------------------------------------------------------------
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