[m-rev.] diff/for review: remove error type as a paramter of stream.input

Ian MacLarty maclarty at csse.unimelb.edu.au
Mon Apr 23 12:02:41 AEST 2007


On Fri, Apr 20, 2007 at 04:35:41PM +1000, Julien Fischer wrote:
> 
> The following diff will break existing code in a fairly minor way;
> the fix is just to delete the error parameter from any stream.input
> instances.
> 
> Estimated hours taken: 1
> Branches: main
> 
> Make the stream error type specific to each reader, not specific to an 
> entire
> input stream.  This means that different readers attached to the same stream
> can return different types of error; this is useful in the case where a
> reader can return a partial result.
> 
> library/stream.m:
> 	Change the definition of input streams so that they no longer include
> 	parameter for the error type.
> 
> 	Introduce the error type as a parameter of the reader class.
> 	This means that different readers attached to the same stream may
> 	now have different error types.  The error type is functionally
> 	dependent upon the reader's handle and unit types.
> 
> library/io.m:
> extras/net/tcp.m:
> 	Conform to the above change.
> 
...
> 
>      % An input stream is a source of data.
>      %
> -:- typeclass stream.input(Stream, State, Error)
> -    <= ( stream(Stream, State), stream.error(Error), (Stream -> Error) )
> -    where [].
> +:- typeclass stream.input(Stream, State) <= stream(Stream, State) where [].
> 
>      % A reader stream is a subclass of specific input stream that can be
>      % used to read data of a specific type from that input stream.
>      % A single input stream can support multiple reader subclasses.
>      %
>  :- typeclass stream.reader(Stream, Unit, State, Error)
> -    <= stream.input(Stream, State, Error) where
> +    <= ( stream.input(Stream, State), stream.error(Error),
> +        (Stream, Unit -> Error)) where
>  [
>      % Get the next unit from the given stream.
>      % The get operation should block until the next unit is available.
> @@ -151,8 +150,8 @@
>      % and destination of data, i.e. it is a both an input and
>      % an output stream.
>      %
> -:- typeclass stream.duplex(Stream, State, Error)
> -    <= ( stream.input(Stream, State, Error), stream.output(Stream, State))
> +:- typeclass stream.duplex(Stream, State)
> +    <= ( stream.input(Stream, State), stream.output(Stream, State))

Put a space before the final parenthesis to be consistent with the space
after the first parenthesis (here and above).

Otherwise that looks fine.

Ian.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list