External Publication
Visit Post

Lazily consuming a self-referential linked list

Haskell Community [Unofficial] May 20, 2026
Source

VegOwOtenks:

I grew tired of explicitly writing fixed-point/worklist algorithms

VegOwOtenks:

Given any queue of workqueue jobs, an initial state and a function to perform a job by updating the state and enqueuing new jobs, compute the final state.

I’m missing the broader picture here, would you care to explain?

My guess: There is a dependency tree of tasks q that possibly hand data to each other, and have access to a common environment s. The abstraction for a task is backwards, so each task can say: “My prerequisite is this number of tasks, that need to have finished before I can run”. The [q] serves as an abstraction for a topological sorting of the forest of dependencies.

Your run function and its arguments apparently attempt to do two things in parallel, that may better be kept separate:

  1. Build the dependency tree of tasks
  2. execute/schedule the tasks

I’d rather start by finding a fitting data abstraction for tasks with dependencies, while keeping the question of scheduling and execution entirely separate. Once you have both, lazyness can still take care of interleaving creating and running the jobs.

Joachim Breitner has a package rec-def that lets you compute fixed points of data structures that are otherwise strict, such as maps and sets.

Discussion in the ATmosphere

Loading comments...