{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreigw7hpedolpiuxgc7b6zpczipdl2ioqfjieb653h47hedlxnl2b2a",
"uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mkuzxfggfkq2"
},
"path": "/t/conduit-to-yield-first-lines-from-file-without-leaking-space-or-file-handles/14030#post_10",
"publishedAt": "2026-05-02T15:19:58.000Z",
"site": "https://discourse.haskell.org",
"tags": [
"(click for more details)"
],
"textContent": "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).\n\nThe important part is that the resource is bracketed in `sourceFileLines` (using `withLine`) and `takeConsume` is completely unaware that there is any resource in scope.\n\nNonetheless, the resources are managed properly and there is only one handle open at any point during this program.\n\nBluefin streaming without leaking handles (click for more details)",
"title": "Conduit to yield first lines from file without leaking space or file handles?"
}