[m-dev.] io streams

Robert Ernst Johann JESCHOFNIK rejj at cat.cs.mu.OZ.AU
Thu Dec 23 11:37:01 AEDT 1999


On Thu, 23 Dec 1999, Michael Day wrote:

> :- type stream__result(T)
> 	--->	ok(T)
> 	;	eof
> 	;	error(string)
> 	.

What would the result be if performing blocking IO (I remember you
mentioning this as a consideration) and not all of what was desired to be
output (for example) was successfully output?

> 	% Interface for streams.
> 
> :- typeclass stream__stream(S) where
> 	[
> 		pred stream__get_name(string, S, S),
> 		mode stream__get_name(out, di, uo) is det
> 	].

I'm curious - if these methods are module qualified like this, does this
mean that I cannot make my own type in a different module, and then make
it an instance?

Hrm, I'm pretty sure that isn't the case.. but I'd rather ask and look
foolish, because at least then I'll know for sure. ;D

> %-----------------------------------------------------------------------------%
> 
> 	% Interface for input streams.
> 
> :- typeclass stream__input(S) <= stream__stream(S) where
> 	[
> 		pred stream__read_char(stream__result(char), S, S),
> 		mode stream__read_char(out, di, uo) is det,
> 
> 		pred stream__read_chars(stream__result(list(char)), int, S, S),
> 		mode stream__read_chars(out, in, di, uo) is det,
> 
> 		pred stream__read_chars(stream__result(list(char)), S, S),
> 		mode stream__read_chars(out, di, uo) is det,
> 
> 		pred stream__putback_char(char, S, S),
> 		mode stream__putback_char(in, di, uo) is det
> 	].

I'd like to see things that let you read in whitespace delimeted words,
and also whole lines. Being able to chew up any trailing whitespace is
also handy. (the io library implements this allready)


> %-----------------------------------------------------------------------------%
> 
> 	% Interface for output streams.
> 
> :- typeclass stream__output(S) <= stream__stream(S) where
> 	[
> 		pred stream__write_char(char, S, S),
> 		mode stream__write_char(in, di, uo) is det,
> 
> 		pred stream__write_chars(list(char), S, S),
> 		mode stream__write_chars(in, di, uo) is det,
> 
> 		pred stream__write_chars(list(char), list(char), S, S),
> 		mode stream__write_chars(in, out, di, uo) is det,
> 		mode stream__write_chars(di, uo, di, uo) is det,
> 
> 		pred stream__flush_output(S, S),
> 		mode stream__flush_output(di, uo) is det
> 	].

Same here, but for output..



Rob

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