<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">I’ve been pointed to <a href="https://github.com/ghc-proposals/ghc-proposals/pull/35">https://github.com/ghc-proposals/ghc-proposals/pull/35</a> where this was debated a few years ago. With much of the same arguments as today.</p>
<p style="margin:0px 0px 1.2em!important">Simon Marlow said</p>
<p style="margin:0px 0px 1.2em!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>making an unboxed tuple binding lazy by default seems to be intuitively
the wrong choice. I guarantee I would get tripped up by this! Giving
unboxed tuples an implicit bang seems reasonable to me.</div></blockquote><p></p></div><p style="margin:0px 0px 1.2em!important"></p>
<p style="margin:0px 0px 1.2em!important">I can share that I got tripped by it. And so were other members of my team.</p>
<p style="margin:0px 0px 1.2em!important">That being said, Richard seemed to feel rather strongly about this one. Richard, do you still agree with your then position that <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">let (#x, y#) = …</code> being a lazy pattern (hence implicitly boxes the pair) is the right semantics?</p>
<div title="MDH:PGRpdj5JJ3ZlIGJlZW4gcG9pbnRlZCB0byBodHRwczovL2dpdGh1Yi5jb20vZ2hjLXByb3Bvc2Fs
cy9naGMtcHJvcG9zYWxzL3B1bGwvMzUgd2hlcmUgdGhpcyB3YXMgZGViYXRlZCBhIGZldyB5ZWFy
cyBhZ28uIFdpdGggbXVjaCBvZiB0aGUgc2FtZSBhcmd1bWVudHMgYXMgdG9kYXkuPC9kaXY+PGRp
dj48YnI+PC9kaXY+PGRpdj5TaW1vbiBNYXJsb3cgc2FpZDwvZGl2PjxibG9ja3F1b3RlIGNsYXNz
PSJnbWFpbF9xdW90ZSIgc3R5bGU9Im1hcmdpbjogMHB4IDBweCAwcHggMC44ZXg7IGJvcmRlci1s
ZWZ0OiAxcHggc29saWQgcmdiKDIwNCwgMjA0LCAyMDQpOyBwYWRkaW5nLWxlZnQ6IDFleDsiPjxk
aXY+bWFraW5nIGFuIHVuYm94ZWQgdHVwbGUgYmluZGluZyBsYXp5IGJ5IGRlZmF1bHQgc2VlbXMg
dG8gYmUgaW50dWl0aXZlbHkgCnRoZSB3cm9uZyBjaG9pY2UuICBJIGd1YXJhbnRlZSBJIHdvdWxk
IGdldCB0cmlwcGVkIHVwIGJ5IHRoaXMhICBHaXZpbmcgCnVuYm94ZWQgdHVwbGVzIGFuIGltcGxp
Y2l0IGJhbmcgc2VlbXMgcmVhc29uYWJsZSB0byBtZS48L2Rpdj48L2Jsb2NrcXVvdGU+PGRpdj5J
IGNhbiBzYXkgdGhhdCBJIGdvdCB0cmlwcGVkIGJ5IGl0LiBBbmQgc28gd2VyZSBvdGhlciBtZW1i
ZXJzIG9mIG15IHRlYW0uPC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5UaGF0IGJlaW5nIHNhaWQs
IFJpY2hhcmQgc2VlbWVkIHRvIGZlZWwgcmF0aGVyIHN0cm9uZ2x5IGFib3V0IHRoaXMgb25lLiBS
aWNoYXJkLCBkbyB5b3Ugc3RpbGwgYWdyZWUgd2l0aCB5b3VyIHRoZW4gcG9zaXRpb24gdGhhdCBg
bGV0ICgjeCwgeSMpID0g4oCmYCBiZWluZyBhIGxhenkgcGF0dGVybiAoaGVuY2UgaW1wbGljaXRs
eSBib3hlcyB0aGUgcGFpcikgaXMgdGhlIHJpZ2h0IHNlbWFudGljcz88YnI+PC9kaXY+" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 28, 2020 at 8:26 PM chessai <<a href="mailto:chessai1996@gmail.com">chessai1996@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Arnaud,<div dir="auto"><br></div><div dir="auto">I have dealt with this in the past and find the laziness extremely counterintuitive and never wanted. Every time I have let-bound an unboxed tuple, I have never wanted that boxing to occur. Perhaps there is a good reason this is the case but I wish it would change.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 28, 2020, 08:26 Spiwack, Arnaud <<a href="mailto:arnaud.spiwack@tweag.io" target="_blank">arnaud.spiwack@tweag.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><p style="margin:0px 0px 1.2em">Hi Carter,</p>
<p style="margin:0px 0px 1.2em">We are using <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">let !(#x,y#) = …</code> actually. Having the strict behaviour is not particularly difficult. You can even use <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">case … of (#x, y#) ->…</code> directly, it’s not too bad. My complaint, as it were, is solely about the potential for mistakes.</p>
<div title="MDH:PGRpdj5IaSBDYXJ0ZXIsPC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5XZSBhcmUgdXNpbmcgYGxl
dCAhKCN4LHkjKSA9IOKApmAgYWN0dWFsbHkuIDxzcGFuIHpldW00YzE5PSJQUl8xXzAiIGRhdGEt
ZGRud2FiPSJQUl8xXzAiIGFyaWEtaW52YWxpZD0iZ3JhbW1hciIgY2xhc3M9IkxtIG5nIj5IYXZp
bmcgdGhlIHN0cmljdDwvc3Bhbj4gYmVoYXZpb3VyIGlzIG5vdCBwYXJ0aWN1bGFybHkgZGlmZmlj
dWx0LiBZb3UgY2FuIGV2ZW4gdXNlIGBjYXNlIOKApiBvZiAoI3gsIHkjKSAtJmd0O+KApmAgZGly
ZWN0bHksIGl0J3Mgbm90IHRvbyBiYWQuIE15IGNvbXBsYWludCwgYXMgaXQgd2VyZSwgaXMgc29s
ZWx5IGFib3V0IHRoZSBwb3RlbnRpYWwgZm9yIG1pc3Rha2VzLjxicj48L2Rpdj4=" style="height:0px;width:0px;max-height:0px;max-width:0px;overflow:hidden;font-size:0em;padding:0px;margin:0px"></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 28, 2020 at 3:20 PM Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com" rel="noreferrer" target="_blank">carter.schonwald@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div dir="auto">Have you tried using do notation for bindings you want to keep strict, with Eg the identity monad? That doesn’t address the design critique but gives you a path forward ? </div></div><div dir="auto"><br></div><div dir="auto">I do agree that the semantics / default recursivity Of let bindings can be inappropriate for non recursive code , but would any other non uniform semantics or optimization be safe?</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 28, 2020 at 9:05 AM Spiwack, Arnaud <<a href="mailto:arnaud.spiwack@tweag.io" rel="noreferrer" target="_blank">arnaud.spiwack@tweag.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><p style="margin:0px 0px 1.2em">Dear all,</p><br><br><p style="margin:0px 0px 1.2em">I discovered the hard way, yesterday, that lazy let pattern<br>matching is allowed on unboxed tuples. And that it implicitly reboxes<br>the pattern.</p><br><br><p style="margin:0px 0px 1.2em">Here is how the manual describes it, from the <a href="https://downloads.haskell.org/ghc/latest/docs/html/users_guide/glasgow_exts.html#extension-UnboxedTuples" rel="noreferrer" target="_blank">relevant section</a>:</p><br><br><blockquote style="margin:1.2em 0px;border-left:4px solid rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none"><br><br><p style="margin:0px 0px 1.2em">You can have an unboxed tuple in a pattern binding, thus</p><br><br><pre style="font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);display:block;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248) none repeat scroll 0% 0%"><span style="color:rgb(153,0,0);font-weight:bold">f</span> x = <span style="color:rgb(51,51,51);font-weight:bold">let</span> (# p,q #) = h x <span style="color:rgb(51,51,51);font-weight:bold">in</span> ..body..<br><br></code></pre><br><br><p style="margin:0px 0px 1.2em">If the types of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">p</code> and <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">q</code> are not unboxed, the resulting binding is lazy like any other Haskell pattern binding. The above example desugars like this:</p><br><br><pre style="font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);display:block;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248) none repeat scroll 0% 0%"><span style="color:rgb(153,0,0);font-weight:bold">f</span> x = <span style="color:rgb(51,51,51);font-weight:bold">let</span> t = <span style="color:rgb(51,51,51);font-weight:bold">case</span> h x <span style="color:rgb(51,51,51);font-weight:bold">of</span> { (# p,q #) -> (p,q) }<br><br> p = fst t<br><br> q = snd t<br><br> <span style="color:rgb(51,51,51);font-weight:bold">in</span> ..body..<br><br></code></pre><br><br><p style="margin:0px 0px 1.2em">Indeed, the bindings can even be recursive.</p><br><br></blockquote><br><br><p style="margin:0px 0px 1.2em">Notice how <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">h x</code> is lazily bound, hence won’t necessarily be run when<br><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">body</code> is forced. as opposed to if I had written, for instance,</p><br><br><pre style="font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);display:block;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248) none repeat scroll 0% 0%"><span style="color:rgb(153,0,0);font-weight:bold">let</span> u = hx<br><br><span style="color:rgb(153,0,0);font-weight:bold">in</span> ..body..<br><br></code></pre><br><br><p style="margin:0px 0px 1.2em">My question is: are we happy with this? I did find this extremely<br>surprising. If I’m using unboxed tuples, it’s because I want to<br>guarantee to myself a strict, unboxed behaviour. But a very subtle<br>syntactic detail seems to break this expectation for me. My<br>expectation would be that I would need to explicitly rebox things<br>before they get lazy again.</p><br><br><p style="margin:0px 0px 1.2em">I find that this behaviour invites trouble. But you may disagree. Let<br>me know!</p><br><br><div title="MDH:RGVhciBhbGwsPGJyPjxicj48c3BhbiB6ZXVtNGMxMD0iUFJfNTNfMCIgZGF0YS1kZG53YWI9IlBS<br><br>XzUzXzAiI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Jy<br><br>Pmd1YXJhbnRlZSB0byBteXNlbGYgYSBzdHJpY3QsIHVuYm94ZWQgYmVoYXZpb3VyLiBCdXQgYSB2<br><br>ZXJ5IHN1YnRsZTxicj5zeW50YWN0aWMgZGV0YWlsIHNlZW1zIHRvIGJyZWFrIHRoaXMgZXhwZWN0<br><br>YXRpb24gZm9yIG1lLiBNeTxicj5leHBlY3RhdGlvbiB3b3VsZCBiZSB0aGF0IEkgd291bGQgbmVl<br><br>ZCB0byBleHBsaWNpdGx5IHJlYm94IHRoaW5nczxicj5iZWZvcmUgPHNwYW4gemV1bTRjMTA9IlBS<br><br>XzU3XzAiIGRhdGEtZGRud2FiPSJQUl81N18wIiBhcmlhLWludmFsaWQ9ImdyYW1tYXIiIGNsYXNz<br><br>PSJMbSBuZyI+dGhlPC9zcGFuPiBnZXQgbGF6eSBhZ2Fpbi48YnI+PGJyPkkgZmluZCB0aGF0IHRo<br><br>aXMgYmVoYXZpb3VyIGludml0ZXMgdHJvdWJsZS4gQnV0IHlvdSBtYXkgZGlzYWdyZWUuIExldDxi<br><br>cj5tZSBrbm93ITxicj48YnI+WzFdOiBodHRwczovL2Rvd25sb2Fkcy5oYXNrZWxsLm9yZy9naGMv<br><br>bGF0ZXN0L2RvY3MvaHRtbC91c2Vyc19ndWlkZS9nbGFzZ293X2V4dHMuaHRtbCNleHRlbnNpb24t<br><br>VW5ib3hlZFR1cGxlczxicj4=" style="height:0px;width:0px;max-height:0px;max-width:0px;overflow:hidden;font-size:0em;padding:0px;margin:0px"></div></div></div><br><br>_______________________________________________<br><br>ghc-devs mailing list<br><br><a href="mailto:ghc-devs@haskell.org" rel="noreferrer" target="_blank">ghc-devs@haskell.org</a><br><br><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br><br></blockquote></div></div>
</blockquote></div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" rel="noreferrer" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>
</blockquote></div>