External Publication
Visit Post

Lazily consuming a self-referential linked list

Haskell Community [Unofficial] May 19, 2026
Source
L0neGamer: > What 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. You’re right, if worded that way it does sound quite impossible. L0neGamer: > I 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! I don’t think I have a solution. I’m in a position where I can control/count the additions to the list and keep that as a balance. As soon as the balance reaches zero I stop evaluating (end-of-list divergence), more of a workaround than a solution, really.

Discussion in the ATmosphere

Loading comments...