# Why don't we use lazy lists in OCaml?

**URL:** <https://discuss.ocaml.org/t/why-dont-we-use-lazy-lists-in-ocaml/16010>\
**Category:** Learning\
**Created:** [January 22, 2025, 9:44pm UTC](https://discuss.ocaml.org/t/why-dont-we-use-lazy-lists-in-ocaml/16010 "2025-01-22T21:44:45Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![bsidhom](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bsidhom/32/5763_2.png) [@bsidhom](https://discuss.ocaml.org/u/bsidhom)\
**Post date:** [January 23, 2025, 1:29am UTC](https://discuss.ocaml.org/t/why-dont-we-use-lazy-lists-in-ocaml/16010/3 "2025-01-23T01:29:25Z")

</div>

Interestingly enough, I had this same question while trying to translate the [Power series, power serious](https://www.cambridge.org/core/journals/journal-of-functional-programming/article/power-series-power-serious/19863F4EAACC33E1E01DE2A2114EC7DF) lazy sequence technique into OCaml. I expected to get a magic speedup switching coefficient representation from bare `Seq.t` to the memoized variant, but it did not perform anywhere near how I expected (or even in the same ballpark as a naive Haskell implementation). I assumed I just had some perf bug somewhere (which may still be the case), but now I wonder how much that can be attributed to Seq memoization.

I’m still curious about what the _expected_ memory retention is in any case. If you do _not_ retain references to the head of a memoized `Seq.t`, is it at least in theory eligible for collection? In particular, I’m trying to understand [this comment](https://github.com/ocaml/ocaml/pull/1002#discussion_r95860980) and why it would even be possible for a tail to retain a reference to some “earlier” head (unless your generating closure was cyclic).

---

_[View the full topic](https://discuss.ocaml.org/t/why-dont-we-use-lazy-lists-in-ocaml/16010)._
