# -XStrict: Why some binders are not made strict?

Simon Peyton Jones simonpj at microsoft.com
Tue Dec 8 14:42:13 UTC 2015

```Adam, Johan,

Looking at the user manual
and indeed the wiki page
it's not really clear whether the sub-components of a pattern are strict.  That is, is the second equation of zip strict in x, and xs?   (Supposing for now that the list data structure is lazy).  The manual doesn't say one way or the other.

Thanks

Simon

| -----Original Message-----
| From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Ömer
| Sinan Agacan
| Sent: 08 December 2015 01:41
| To: ghc-devs <ghc-devs at haskell.org>
| Subject: -XStrict: Why some binders are not made strict?
|
| Let's say I have this code:
|
|     zip :: [a] -> [b] -> [(a, b)]
|     zip [] [] = []
|     zip (x : xs) (y : ys) = (x, y) : zip xs ys
|
| With -XStrict 'x', 'xs', 'y' and 'ys' don't become strict. I'm wondering
| the motivation behind this, I found this interesting. I always thought -
| XStrict
| gives me this guarantee: If I'm using an already-defined variable(bound by
| a
| let or pattern matching) in an expression, I can be sure that the variable
| won't be bottom in that expression, because it would be `seq`d before the
| expression is evaluated.
|
| So if I have
|
|     case ... of
|         D x y -> <body>
|
| or
|
|     let x = ...
|         y = ...
|      in <body>
|
| In both cases I was thinking that in <body> 'x' and 'y' can't be
| bottom(with
| -XStrict). This would make -XStrict programs evaluate like they would in a
| call-by-value language(even though in the RTS level thunks will be built).
| Variables can't range over computations; all binders evaluated strictly
| etc.
|
| Can anyone tell me about the motivation behind this decision?
|
| I think the wiki page actually conflicts with itself. It says "...
| bindings to be
| strict by default" but then in "case expressions" sections says
|
|     case x of (a,b) -> rhs
|
|     is interpreted as
|
|     case x of !(a,b) -> rhs
|
| Here bindings 'a' and 'b' are not made strict. I'd expect something like:
|
|     case x of (!a,!b) -> rhs
|
| (Which seems to be invalid Haskell, but same effect could be achieved with
| `seq
| a (seq b rhs)`)
|
| Thanks..
|
| (I also realized that the wiki page doesn't mention bindings in do syntax,
| is
| it because this case is implied by "function definitions"? That is, bangs
| are
| added after do syntax is desugared and so they become strict?)
| _______________________________________________
| ghc-devs mailing list