Gabriella439 / pipes

Compositional pipelines
BSD 3-Clause "New" or "Revised" License
487 stars 72 forks source link

Fix space leak when using `forever` #208

Closed Gabriella439 closed 5 years ago

Gabriella439 commented 5 years ago

Related to https://github.com/Gabriel439/Haskell-Pipes-Library/issues/15#issuecomment-522994157

forever began to leak for pipes in #194 due to removing the leak-free implementation of the (*>) operator.

Specifically, forever is implemented as:

forever a = let a' = a *> a' in a'

... and in the absence of a specialized implementation of the (*>) operator, it falls back on the default implementation, which is:

a1 *> a2 = (id <$ a1) <*> a2

Unfortunately, that implementation leaks space, which is why pipes requires a more efficient implementation, which this change restores.