Make lines stricter to fix a space leak
igloo at earth.li
Sat Sep 25 07:30:11 EDT 2010
On Sat, Sep 25, 2010 at 03:45:15AM +0200, Daniel Fischer wrote:
> On Saturday 25 September 2010 02:55:24, Ian Lynagh wrote:
> > On Fri, Sep 24, 2010 at 09:21:19PM +0200, Daniel Fischer wrote:
> > > Proposal: A stricter implementation of lines.
> > >
> > > Reason: The current implementation causes a space leak (cf.
> > > http://homepages.inf.ed.ac.uk/wadler/papers/leak/leak.ps), at least in
> > > GHC.
> > >
> > > The proposed implementation fixes the leak at the small cost of being
> > > stricter if the first _|_ in the String is the first character of a
> > > line.
> > I think this changes the definition from one that currently has a space
> > leak with GHC, to one which necessarily must have a space leak (as all
> > of l must be held in memory while we look for a newline).
> No, with the proposed implementation, e.g. counting line lengths runs in
> constant space:
Ah, yes, you are right, sorry. I don't have a strong opinion, then.
We ought to put the old definition into the H98 and H2010 packages,
though. Hmm, but currently Prelude always comes from base.
More information about the Libraries