This whole area is clearly somewhat troublesome:

> On Sep 10, 2020, at 12:05 PM, Iavor Diatchki <iavor.diatc...@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
_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Reply via email to