Text I/O library proposal, first draft
John Meacham
john@repetae.net
Thu, 31 Jul 2003 23:45:53 -0700
this can all be done safely in the state monad (when using external c
calls or not). I vaugly remember a binding to iconv floating around
which was based on the state monad. there was also an implementation
(based on IO, but rather advanced) in the qforeign distribution which
might be useful to look at.. (See Conv*.hs)
John
On Thu, Jul 31, 2003 at 11:19:48PM -0700, Ben Rudiak-Gould wrote:
> On Fri, 1 Aug 2003, Glynn Clements wrote:
>
> > Ben Rudiak-Gould wrote:
> >
> > > -- A BlockRecoder takes source and destination buffers and does some sort
> > > -- of translation between them. It returns the number of values (not
> > > -- bytes!) consumed and the number of values produced. It does not have to
> > > -- empty the input buffer or fill the output buffer on each call, but it
> > > -- must do something (i.e. it's not acceptable to return (0,0)). Coders
> > > -- will in general have internal state which is updated on each call.
> >
> > It would be preferable if this wasn't all within the IO monad. It
> > shouldn't be necessary, even for stateful encodings.
>
> The problem is that all the Ptr access functions are in the IO monad.
> Switching to a different monad would require the use of unsafePerformIO or
> unsafeIOtoST, and I couldn't see any obvious way to guarantee safety. It
> seems better for the library user to make the unsafe conversions
> explicitly if they're to be made at all.
>
> The other possibility would be to drop the Ptrs and use STUArrays or
> immutable data structures, but I think that would inevitably be less
> efficient (especially given that many/most text coders are likely to be
> implemented using libc functions), and the standard text I/O library needs
> to be efficient.
>
> -- Ben
>
> --
> Libraries mailing list
> Libraries@haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
--
---------------------------------------------------------------------------
John Meacham - California Institute of Technology, Alum. - john@foo.net
---------------------------------------------------------------------------