!RE: Implicit reboxing of unboxed tuple in let-patterns

Richard Eisenberg rae at richarde.dev
Thu Sep 10 16:18:32 UTC 2020


This whole area is clearly somewhat troublesome:

> On Sep 10, 2020, at 12:05 PM, Iavor Diatchki <iavor.diatchki at gmail.com> wrote:
> 
> 3. nested bang patterns in pattern bindings should count as "uses" of the value and therefore should be strict.  For example if I write `let ( !x, !y ) = undefined in ()`, I think this should be equivalent to `let (x,y) = undefined in x `seq` y `seq` ()`.  With the current behavior the bang patterns don't do anything, while my guess would be that most people would expect the suggested behavior instead.  As usual, we should not allow that at the top level.

This isn't quite right.

Consider

> ex0 = let ( !x, !y ) = undefined in ()
> ex1 = let ( !x, !y ) = (5, undefined) in x
> ex2 = let ( !x, y )  = (5, undefined) in x

ex0 converges, because let-bindings are lazy by default.
ex1 diverges, because the bang on y means that, when the patten-match happens at all, x and y are bound strictly. So bangs *do* matter in nested patterns within pattern bindings. By contrast, ex2 converges.

Again, I'm not arguing in favor of the current behavior, but I want to make sure we're all as informed as possible in this debate.

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20200910/082d9672/attachment.html>


More information about the ghc-devs mailing list