<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>When implementing I took this:<br></div>
<div> </div>
<div>> Notice that we do not put bangs on nested patterns. For example<br></div>
<div>>   let (p,q) = if flob then (undefined, undefined) else (True, False)<br></div>
<div>>    in ...<br></div>
<div>> will behave like<br></div>
<div>>   let !(p,q) = if flob then (undefined, undefined) else (True, False)<br></div>
<div>>   in ...<br></div>
<div> </div>
<div>(from the spec) and applied it to all bindings, but I don't know if this is the best implementation.<br></div>
<div> </div>
<div>Cheers,</div>
<div id="sig22230037"><div class="signature">Adam <br></div>
</div>
<div> </div>
<div> </div>
<div>On Thu, 10 Dec 2015, at 03:34 PM, Johan Tibell wrote:<br></div>
<blockquote type="cite"><div dir="ltr">I'm snowed under but I promise I will try to reply soon! To think about in the mean time: what do existing strict languages with pattern matching do?<br></div>
<div><div> </div>
<div><div>On Tue, Dec 8, 2015 at 3:42 PM, Simon Peyton Jones <span dir="ltr"><<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>></span> wrote:<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex;"><div>Adam, Johan,<br></div>
<div> </div>
<div>
Looking at the user manual<br></div>
<div> <a href="http://downloads.haskell.org/~ghc/master/users-guide/glasgow_exts.html#strict-haskell">http://downloads.haskell.org/~ghc/master/users-guide/glasgow_exts.html#strict-haskell</a>,<br></div>
<div>
and indeed the wiki page<br></div>
<div> <a href="https://ghc.haskell.org/trac/ghc/wiki/StrictPragma">https://ghc.haskell.org/trac/ghc/wiki/StrictPragma</a><br></div>
<div>
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.<br></div>
<div> </div>
<div>
What's the answer?  And could the user manual please say?<br></div>
<div> </div>
<div>
Thanks<br></div>
<div> </div>
<div>
Simon<br></div>
<div><div><div> </div>
<div>
| -----Original Message-----<br></div>
<div>
| From: ghc-devs [mailto:<a href="mailto:ghc-devs-bounces@haskell.org">ghc-devs-bounces@haskell.org</a>] On Behalf Of Ömer<br></div>
<div>
| Sinan Agacan<br></div>
<div>
| Sent: 08 December 2015 01:41<br></div>
<div>
| To: ghc-devs <<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>><br></div>
<div>
| Subject: -XStrict: Why some binders are not made strict?<br></div>
<div>
|<br></div>
<div>
| Let's say I have this code:<br></div>
<div>
|<br></div>
<div>
|     zip :: [a] -> [b] -> [(a, b)]<br></div>
<div>
|     zip [] [] = []<br></div>
<div>
|     zip (x : xs) (y : ys) = (x, y) : zip xs ys<br></div>
<div>
|<br></div>
<div>
| With -XStrict 'x', 'xs', 'y' and 'ys' don't become strict. I'm wondering<br></div>
<div>
| about<br></div>
<div>
| the motivation behind this, I found this interesting. I always thought -<br></div>
<div>
| XStrict<br></div>
<div>
| gives me this guarantee: If I'm using an already-defined variable(bound by<br></div>
<div>
| a<br></div>
<div>
| let or pattern matching) in an expression, I can be sure that the variable<br></div>
<div>
| won't be bottom in that expression, because it would be `seq`d before the<br></div>
<div>
| expression is evaluated.<br></div>
<div>
|<br></div>
<div>
| So if I have<br></div>
<div>
|<br></div>
<div>
|     case ... of<br></div>
<div>
|         D x y -> <body><br></div>
<div>
|<br></div>
<div>
| or<br></div>
<div>
|<br></div>
<div>
|     let x = ...<br></div>
<div>
|         y = ...<br></div>
<div>
|      in <body><br></div>
<div>
|<br></div>
<div>
| In both cases I was thinking that in <body> 'x' and 'y' can't be<br></div>
<div>
| bottom(with<br></div>
<div>
| -XStrict). This would make -XStrict programs evaluate like they would in a<br></div>
<div>
| call-by-value language(even though in the RTS level thunks will be built).<br></div>
<div>
| Variables can't range over computations; all binders evaluated strictly<br></div>
<div>
| etc.<br></div>
<div>
|<br></div>
<div>
| Can anyone tell me about the motivation behind this decision?<br></div>
<div>
|<br></div>
<div>
| I think the wiki page actually conflicts with itself. It says "...<br></div>
<div>
| bindings to be<br></div>
<div>
| strict by default" but then in "case expressions" sections says<br></div>
<div>
|<br></div>
<div>
|     case x of (a,b) -> rhs<br></div>
<div>
|<br></div>
<div>
|     is interpreted as<br></div>
<div>
|<br></div>
<div>
|     case x of !(a,b) -> rhs<br></div>
<div>
|<br></div>
<div>
| Here bindings 'a' and 'b' are not made strict. I'd expect something like:<br></div>
<div>
|<br></div>
<div>
|     case x of (!a,!b) -> rhs<br></div>
<div>
|<br></div>
<div>
| (Which seems to be invalid Haskell, but same effect could be achieved with<br></div>
<div>
| `seq<br></div>
<div>
| a (seq b rhs)`)<br></div>
<div>
|<br></div>
<div>
| Thanks..<br></div>
<div>
|<br></div>
<div>
| (I also realized that the wiki page doesn't mention bindings in do syntax,<br></div>
<div>
| is<br></div>
<div>
| it because this case is implied by "function definitions"? That is, bangs<br></div>
<div>
| are<br></div>
<div>
| added after do syntax is desugared and so they become strict?)<br></div>
<div>
| _______________________________________________<br></div>
<div>
| ghc-devs mailing list<br></div>
<div>
| <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br></div>
</div>
</div>
<div>| <a href="https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.haske">https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.haske</a><br></div>
<div>
| <a href="http://ll.org">ll.org</a>%2fcgi-bin%2fmailman%2flistinfo%2fghc-<br></div>
<div>
| devs&data=01%7c01%7csimonpj%<a href="http://40064d.mgd.microsoft.com">40064d.mgd.microsoft.com</a>%7cbc68c0830f574466efd<br></div>
<div>
| 308d2ff70aba9%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=c2VBbt%2f%2fR2c<br></div>
<div>
| yFecGEuQotO%2bV71VSbpmWnZJyV9d8KRk%3d<br></div>
</blockquote></div>
</div>
</blockquote><div> </div>
</body>
</html>