[Haskell-cafe] Terminology: different levels of strictness

Edward Z. Yang ezyang at MIT.EDU
Fri Jan 27 16:31:56 CET 2012

There are some terms for these cases, but they are a bit ad hoc.
length is what we might call spine-strict; head is head-strict.

Projection analysis takes the approach that we can more precisely
characterize the strictness only by considering both what is passed
to the function as input, as well as how much is demanded by the
context (for example, you might return a tuple, one of the values
of which causes lots of evaluation, and the other of which doesn't.)
Unfortunately, this is not enough precision to consider elem.


Excerpts from Yves Parès's message of Fri Jan 27 10:13:54 -0500 2012:
> If I consider the functions head, length, elem & sum, each is of them is
> strict, as:
> head/length/elem x/sum _|_ are always _|_.
> However:
> head (x:_|_) is never _|_.
> length [_|_, _|_, _|_ ...] is also never _|_.
> elem x [4,5,6,8,2,90,_|_,_|_ ...] is *only sometimes *_|_ (depending on x
> value).
> In fact, only
> sum [4,5,6,8,2,90,_|_,_|_ ...] is always _|_.
> Which shows they don't have the same level of strictness.
> So can you say things like "all these functions are strict, but some are *more
> *than other", or "sum is *deeply strict*" ...?
> What terms can you use to compare those functions?

More information about the Haskell-Cafe mailing list