{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreifbld6xptlr2ih4mb5frhgg6dvkv5p45a4pclnivtnylfgy3734uq",
"uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mmabiulc33x2"
},
"path": "/t/lazily-consuming-a-self-referential-linked-list/14131#post_10",
"publishedAt": "2026-05-19T19:57:18.000Z",
"site": "https://discourse.haskell.org",
"textContent": "VegOwOtenks:\n\n> `run :: [q] -> s -> (q -> s -> [q] -> ([q], s)) -> s`\n\nThis looks to me as if the `[q]` is really part of the state being modified:\n\n\n data PipelineState = PS {globalState :: s, jobs :: [q]}\n run :: PipelineState -> (q -> PipelineState -> PipelineState) -> s\n\n\nand supposedly the final `s` is really a `PS s []`, no more jobs to do. Now I wonder: Why does the `action` argument of `run` have an extra `q` argument at all, when it could pop one off the `[q]`? Perhaps that is the missing occasion for pattern-matching on the empty list? So suppose you could merge `run` and `go` into a single recursive function that does not need the extra `q` for non-emptyness. Suppose further that we agree the final state is just a special `PipelineState`. Now a function with the signature\n\n\n run :: x -> (x -> x) -> x\n\n\nlooks like something that seeks the least fixed point of an endo-function above a given starting value, as per Kleeneās fixed point theorem.",
"title": "Lazily consuming a self-referential linked list"
}