# [Haskell-cafe] Why is this strict in its arguments?

John Meacham john at repetae.net
Tue Dec 4 18:55:47 EST 2007

```On Tue, Dec 04, 2007 at 03:35:28PM -0800, Ryan Ingram wrote:
> On 12/4/07, Stefan O'Rear <stefanor at cox.net> wrote:
> Well, one usually says something like "f is strict in its 2nd argument"
> which on casual reading tends to make me think that it has something to do
> with the argument.  By the actual definition, however, f _ _ = undefined is
> strict in all of its arguments; but it's clear from the definition that the
> arguments are irrelevant.

this becomes more clear if you translate strictness into a logical
representation.

f x y = z

saying f is strict in y is equivalent to

y diverges implies z diverges.

note that this is a one way implication.

so, if z diverges, then the implication is trivially satisfied, as it is
if y doesn't diverge, however if y diverges then z must diverge and that
is what strictness means.

or equivalantly

z diverges \/  ! y diverges

for an example of why this is useful think of the following

imagine we know we are applying a function f to _|_, and we know f is
strict in its first argument. Knowing it is strict, we can elide the
call to f altogether and return bottom immediately. this is true whether
f examines it's argument or not, since f _|_ = _|_ and we know we are
passing _|_ then we can just return _|_. This is one of many
optimizations that 'strictness analysis' allows.

John

* note, I am using 'x diverges' and 'x is bottom' to mean the same
thing. Not all agree this is correct usage, even sometimes I don't.
but for the purposes of this it is fine IMHO.

--
John Meacham - ⑆repetae.net⑆john⑈
```