External Publication
Visit Post

Conduit to yield first lines from file without leaking space or file handles?

Haskell Community [Unofficial] May 2, 2026
Source

You can see an implementation in Bluefin below, analogous to the conduit implementation. There is no established way of doing this in Bluefin so I just cooked up a reasonable API. It differs from conduit in ways that are solvable and not substantive to this question (uses hGetLine rather than having a pipeline component for splitting into lines).

The important part is that the resource is bracketed in sourceFileLines (using withLine) and takeConsume is completely unaware that there is any resource in scope.

Nonetheless, the resources are managed properly and there is only one handle open at any point during this program.

Bluefin streaming without leaking handles (click for more details)

Discussion in the ATmosphere

Loading comments...