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

Stefan O'Rear stefanor at cox.net
Tue Dec 4 18:51:23 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:
> >
> > "Is there a reason why 2 + 2 is defined as 4 instead of, for example,
> > 5?"
> Wow.  That wasn't really necessary.  4 has a clear meaning (the number after
> the number after the number after the number after zero) which is equivalent
> to 2 + 2.  I'm not talking about naming issues; you could say that 5 was
> that number but then nobody would know what you are talking about.  I am
> asking about the history & motivation behind the original definition of
> strictness, not arguing for a redefinition.

Oh.  Sorry.

> > Strictness is more useful in practice, simpler to define, and easier to
> > approximate.
> Please elaborate; this is exactly why I asked.  In particular, "more useful
> in practice" is the thing I am most curious about.

When you see an expression of the form:

f a

you generally want to evaluate a before applying; but if a is _|_, this
will only give the correct result if f a = _|_.  Merely 'guaranteed to
evaluate' misses out on some common cases, for instance ifac:

ifac 0 a = a
ifac n a = ifac (n - 1) (a * n)

ifac is guaranteed to either evaluate a, or go into an infinite loop -
so it can be found strict, and unboxed.  Whereas 'ifac -1 (error "moo")'
is an infinite loop, so using a definition based on evaluation misses
this case.

> > What benefit does your notion offer?
> 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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20071204/b103504a/attachment.bin

More information about the Haskell-Cafe mailing list