[m-dev.] for discussion: stream library v2

Ralph Becket rbeck at microsoft.com
Fri Sep 29 22:01:00 AEDT 2000


>From Fergus Henderson on 29/09/2000 11:32:30
> 	main -->
> 		with_stream(..., (pred(di, uo) is det -->
> 			write_char('x')
> 		).
> 
> would have the effect of
> 
> 	(1) opening a stream (using the file name or whatever other
> 	    parameters are specified in the "..."); and then
> 
> 	(2) invoking the lambda expression that was passed as argument
> 	    to with_stream, passing it the stream that was opened in
> 	    (1); and finally
> 
> 	(3) when the lambda expression exits (whether by returning or
> 	    by throwing an exception), close the stream
> 
> 	(4) if the lambda expression exited by throwing, rethrow the
> 	    exception

This smells suspiciously of monadic IO to me :)

--
Ralph Becket      |      MSR Cambridge      |      rbeck at microsoft.com 

--------------------------------------------------------------------------
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