[Haskell-cafe] Code review: list-like datatype with constant time appending based on function composition.
Arie Peterson
ariep at xs4all.nl
Tue Nov 18 16:37:25 UTC 2014
> What about my doubts on why it works so lazily?
Suppose 'f' is the function '(1 :)', and 'g' is some other unspecified other
function of type '[Integer] -> [Integer]' ("difference list").
You may evaluate the concatenation '(f . g) []' like this:
(f . g) []
= f (g [])
= 1 : g []
and at this point, you already have partial knowledge of the resulting list.
Note that we use "lazy evaluation", in the sense that we do not evaluate the
argument 'g []' to the function 'f' right away, but proceed by first
substituting the definition of 'f'.
More information about the Haskell-Cafe
mailing list