{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiati4yacmarahbvs7oc55ngopit7ictnl4fqileahlrq7nfggtdwq",
"uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mm7gmtnrvdf2"
},
"path": "/t/lazily-consuming-a-self-referential-linked-list/14131#post_4",
"publishedAt": "2026-05-19T08:53:02.000Z",
"site": "https://discourse.haskell.org",
"tags": [
"TardisT"
],
"textContent": "tobz619:\n\n> VegOwOtenks:\n>\n>>\n>> go :: [q] -> s -> (q -> s -> [q] -> ([q], s)) -> ([q], s)\n>> go qs s0 f = case qs of\n>> [] -> ([], s0)\n>> q:rest -> let\n>> (qs1, s1) = f q s0 qs2 -- why is this qs2 and not rest?\n>> (qs2, s2) = go rest s1 f -- why is this rest and not qs1?\n>> in (qs1, s2) -- why is this qs1 and not qs2?\n>>\n\nThe order is like this because it allows the list that is build-up to travel-backwards along the computation, like it would with TardisT. This enables cheap list-building (only cons, no concatenation) while preserving FIFO semantics.",
"title": "Lazily consuming a self-referential linked list"
}