{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreihxrhpvmjpm7n4axc7tcwkjdoua7qznv4eik7jtah72qtyvg62bai",
"uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mm7gm4ky3o42"
},
"path": "/t/lazily-consuming-a-self-referential-linked-list/14131#post_7",
"publishedAt": "2026-05-19T12:24:18.000Z",
"site": "https://discourse.haskell.org",
"textContent": "Reasoning about self-recursive types for a second, does it make sense that a self-recursive type can completely consume itself?\n\nIf we take just a typical infinite list, we know that we cannot guarantee that we process all of it; we must either work on only some subset of it (take a prefix or search through it), or perform an operation that occurs over the entire list lazily (`fmap` or `foldr` with a function lazy in the second argument).\n\nWhat you’re trying to do here is produce a potentially infinite list as well as consume it in its entirety, and I think that that has issues.\n\nI spent some time trying to use lazy writer and Endo to get some “efficient” concatenation but kept running up against looping code and end of list evaluations. I’d be interested in a solution if someone finds one!",
"title": "Lazily consuming a self-referential linked list"
}