[mercury-users] network programming

Peter Schachte pets at students.cs.mu.OZ.AU
Tue Mar 10 15:05:19 AEDT 1998


On Tue, 10 Mar 1998, Fergus Henderson wrote:

> Mission Critical's changes to the Mercury library have not yet been
> merged back into the standard distribution because of a few concerns
> we had about them.  See the attached mail.

[the attachment:]

> > +:- type io__stream.				% Paul
> > +:- type io__bi_stream.				% Paul
> > +:- type io__input_stream ==	io__stream.
> > +:- type io__output_stream ==	io__stream.
> > +:- type io__bi_stream ==	io__stream.   	% Paul.
> > +:- type io__binary_stream ==	io__stream.
>
> Hmm.  This has the disadvantage of losing some type checking.
> For example, the compiler won't complain if you pass an input_stream
> where an output_stream is expected.
> 
> I think I might prefer
> 
> 	:- type bidirectional_stream
> 		---> bidirectional_stream(
> 				input_stream,
> 				output_stream
> 		     ).

Now that Mercury supports type classes, how about having input_stream
and output_stream type classes, and have bidirectional_stream be
instances of both?  This also has the very pleasant advantage of
allowing users to invent their own kinds of streams.  And the other
pleasant advantage of having the Mercury library actually *use* type
classes.


-Peter Schachte			| It is much easier to apologize than to ask
pets at cs.mu.OZ.AU		| permission. -- Grace Murray Hopper 
http://www.cs.mu.oz.au/~pets/	| 
PGP key available on request	| 




More information about the users mailing list