
On Monday 04 October 2010 19:32:54, Henning Thielemann wrote:
Daniel Fischer schrieb:
On Monday 27 September 2010 22:18:40, Daniel Fischer wrote:
Although the Core looks as though it might leak,
And with 6.8.3 it does leak indeed, but no more with 6.10.* and 6.12.*. All produced identical Core, so it's probably a change in the garbage collector.
How can we be sure it runs in constant memory in future GHC versions?
We can't.
Or in other Haskell compilers?
Nor can we here. If it doesn't work for other compilers, #ifdef __GLASGOW_HASKELL__ would be a workaround.
Those fixes to memory leaks look very fragile to me.
Yes, they are fragile. However, since (to my surprise) uncurry isn't available in Data.List, I've tried with a special function for uncurry (:), cons :: (a,[a]) -> [a] cons (x,xs) = x : xs vlines :: String -> [String] vlines "" = [] vlines s = cons $ case break (== '\n') s of (l, s') -> (l, case s' of [] -> [] _:s'' -> vlines s'') , which gives slightly less fragile looking Core ( case GHC.List.$wbreak @ GHC.Types.Char lvl_rjf wild_B1 of _ { (# ww1_aiR, ww2_aiS #) -> GHC.Types.: @ [GHC.Types.Char] ww1_aiR (case ww2_aiS of _ { [] -> GHC.Types.[] @ [GHC.Types.Char]; : _ s''_adv -> VLines.vlines s''_adv }) --the second argument of (:) doesn't contain a reference to the first anymore). Well, 6.8.3 does also leak with that, but that also leaks with a naked case. So yeah, it's a fragile fix, but IMO better than leaving the space leak unattended because we haven't a perfect solution.