[Haskell-cafe] Confused about Cyclic struture

Bernard Pope bjpop at cs.mu.OZ.AU
Tue Jul 12 02:23:19 EDT 2005

On Sat, 2005-07-09 at 13:12 +0400, Bulat Ziganshin wrote:
> Hello Dinh,
> Friday, July 08, 2005, 9:12:22 PM, you wrote:
> DTTA>   Another question, it's said in the book that using cyclic structure (like 
> DTTA> ones = 1:ones) , the list would be represented by a fixed amount of memory.
> DTTA>   Does it mean [1,1,1......] only occupy one cell of memory ?
> DTTA>   How about  in " take 100 [1,1,...] " ?
> in order to understand how Haskell datastructures uses memory, you
> must remember that Haskell does LAZY evaluation. 


I'll be a little bit pedantic here. Haskell, the language definition,
does not prescribe lazy evaluation. It says that the language is
non-strict. Lazy evaluation is an implementation technique which
satisfies non-strict semantics, but it is not the only technique which
does this.

As it happens, GHC, Hugs and nhc98 all employ lazy evaluation. Note that
they may still vary in subtle ways as to the precise details of
evaluation order, due to program transformations that may be applied to
the program during compilation.

As I said in my previous mail, the degree of sharing you get within
Haskell data structures is not defined in the language, it is defined
(perhaps loosely) by the implementation technique. 


More information about the Haskell-Cafe mailing list