[Haskell-cafe] *GROUP HUG*

Stephen Tetley stephen.tetley at gmail.com
Tue May 24 19:03:26 CEST 2011

On 24 May 2011 13:41, Johannes Waldmann <waldmann at imn.htwk-leipzig.de> wrote:

> I could just store the length of the list - as an additional argument
> to the "Cons" constructor that is automatically initialized on construction
> (and you never need to change it later, since Haskell objects
> are "immutable", in the words of Java programmers)
> In Haskell, the reason for not doing this (besides simplicity, and inertia)
> actually is (I think) laziness: you don't want to evaluate
> the "length" field of the second argument of the "cons" prematurely.

Neither OCaml nor PLT Scheme cache the length or they didn't a year of
two ago when someone asked this question on the Haskell Beginners list
and I checked the respective source trees. As the PLT Scheme list was
implemented in C at the time (maybe it still is?) I was a bit
surprised by this.

More information about the Haskell-Cafe mailing list