[mercury-users] Extending library modules, such as io.m (was: Re: zlib binding)

Ian MacLarty maclarty at csse.unimelb.edu.au
Fri Dec 1 18:08:37 AEDT 2006


On Fri, Dec 01, 2006 at 03:50:05PM +1100, Ondrej Bojar wrote:
> Hi,
> 
> Peter, thanks for the sample.
> 
> I'm now trying to copy-paste some io.m routines to a new module and 
> replace the very 'fopen' with gzopen (keeping all intermediate helper 
> functions like in io.m). However, I would but produce 'genuine' 
> io.input_stream.
> 
> This is something that goes very much against the spirit of module 
> encapsulation, because my module would need to have access to io.m's 
> internal data constructors.
> 
> I wish to create a genuine io.input_stream, because then I can use the 
> normal io predicates and functions. If all the useful library functions 
> relied on type classes, there would be no need to fake io.input_stream, 
> I would just instantiate core reader functions for a new gzinput_stream 
> type.
> 
> Is there a way to hack it around now, or should I wait (indefinitely) 
> for the library to switch to type classes?
> 

We already have a stream typeclass system.  See the stream.m module in
the standard library.  It's not documented in the library reference on
the web page, because ceres (the machine the rebuilds the web site) has
had some problems lately.

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



More information about the users mailing list