Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat are Haskell's strictness points?
    primarykey
    data
    text
    <p>We all know (or should know) that Haskell is lazy by default. Nothing is evaluated until it must be evaluated. So when must something be evaluated? There are points where Haskell must be strict. I call these "strictness points", although this particular term isn't as widespread as I had thought. According to me:</p> <blockquote> <p>Reduction (or evaluation) in Haskell <em>only</em> occurs at strictness points.</p> </blockquote> <p>So the question is: <strong>what, <em>precisely</em>, are Haskell's strictness points?</strong> My intuition says that <code>main</code>, <code>seq</code> / bang patterns, pattern matching, and any <code>IO</code> action performed via <code>main</code> are the primary strictness points, but I don't really know why I know that.</p> <p>(Also, if they're not called "strictness points", what <em>are</em> they called?)</p> <p>I imagine a good answer will include some discussion about WHNF and so on. I also imagine it might touch on lambda calculus.</p> <hr> <p><em>Edit: additional thoughts about this question.</em></p> <p>As I've reflected on this question, I think it would be clearer to add something to the definition of a strictness point. Strictness points can have varying <em>contexts</em> and varying <em>depth</em> (or strictness). Falling back to my definition that "reduction in Haskell only occurs at strictness points", let us add to that definition this clause: "a strictness point is only triggered when its surrounding context is evaluated or reduced."</p> <p>So, let me try to get you started on the kind of answer I want. <code>main</code> is a strictness point. It is specially designated as the primary strictness point of its context: the program. When the program (<code>main</code>'s context) is evaluated, the strictness point of main is activated. Main's depth is maximal: it must be fully evaluated. Main is usually composed of IO actions, which are also strictness points, whose context is <code>main</code>.</p> <p>Now you try: discuss <code>seq</code> and pattern matching in these terms. Explain the nuances of function application: how is it strict? How is it not? What about <code>deepseq</code>? <code>let</code> and <code>case</code> statements? <code>unsafePerformIO</code>? <code>Debug.Trace</code>? Top-level definitions? Strict data types? Bang patterns? Etc. How many of these items can be described in terms of just seq or pattern matching?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload