[m-rev.] for review: stream typeclasses
Ian MacLarty
maclarty at csse.unimelb.edu.au
Mon Oct 23 18:28:27 AEST 2006
On Mon, Oct 23, 2006 at 05:33:06PM +1000, Peter Ross wrote:
> On Mon, Oct 23, 2006 at 04:38:36PM +1000, Julien Fischer wrote:
> > Estimated hours taken: 30 (+ unknown by Ian) (+ unknown late last year)
> > Branches: main
> >
> > Add a new module to the standard library that provides generic stream
> > handling via a family of typeclasses. This subsumes the functionality
> > provided by the existing stream library in extras and improves upon that
> > design in several ways.
> >
> > This incarnation of streams is parameterized over the state that is
> > updated by the stream operations, i.e. it is no longer restricted to
> > just being the I/O state**. Streams are also parameterized over the
> > type of the data being written to, or read from, them. This allows for
> > efficient implementations of operations like write_string, and also
> > allows the put and get methods for a single stream to be overloaded.
> >
> > Subsequent diffs will extend the io module to make the standard file
> > streams instances of these typeclasses and convert things like the
> > pretty printer and term_to_xml to use them as well.
> >
> > ** Limitations in the current implementation of typeclasses currently
> > make this less useful than it might initially appear.
> >
> What limitations?
>
I think it's mainly the limitations on instance declarations. So, for
example, you can't have the instance:
:- instance stream.output(buffering_stream(Stream), Unit, State)
<= stream.output(Stream, Unit, State).
Instead we can only have more restricted instances like:
:- instance stream.output(buffering_stream(Stream), string, io)
<= stream.output(Stream, string, io).
...
> The only issue that I can think of is to do with the issue that you have
> a di/uo state pair. Does this mean that there is going to be a problem
> with nested uniqueness?
>
It won't be a problem for now, since almost all the streams will just
update the io state.
> For a concrete example, an encrypt/decrypt stream which is layered on
> top of another stream.
>
Here the encrypt/decrypt stream would update the same state as the
stream it's layered on top of, so there's no nesting of the states.
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