Make lines stricter to fix a space leak

Simon Marlow marlowsd at
Sun Sep 26 06:33:09 EDT 2010

On 25/09/10 12:30, Ian Lynagh wrote:
> 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.
>>>>, 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.

Actually the haskell2010 package has its own Prelude, which could be 
different from the one in base if we wish.


More information about the Libraries mailing list