<div dir="ltr">I believe this is just a bug, since the desugaring ought to be strict in the \x.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 8, 2015 at 6:35 PM, Ömer Sinan Ağacan <span dir="ltr"><<a href="mailto:omeragacan@gmail.com" target="_blank">omeragacan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think this is a problem/bug in the implementation. In the "function<br>
definitions" section of the wiki page it says the argument will have a<br>
bang pattern. But then this code:<br>
<br>
do x <- ...<br>
return (x + 1)<br>
<br>
which is just a syntactic sugar for `... >>= \x -> return (x + 1)`<br>
doesn't have the bang pattern in `x`.<br>
<br>
(See also a related email I sent to ghc-devs yesterday:<br>
<a href="https://mail.haskell.org/pipermail/ghc-devs/2015-December/010699.html" rel="noreferrer" target="_blank">https://mail.haskell.org/pipermail/ghc-devs/2015-December/010699.html</a>)<br>
<div class="HOEnZb"><div class="h5"><br>
2015-12-08 12:27 GMT-05:00 David Kraeutmann <<a href="mailto:kane@kane.cx">kane@kane.cx</a>>:<br>
> While there's a fundamental difference between (>>=) and let-bindings, it<br>
> might be worth adding to the docs that -XStrict only makes let bindings<br>
> strict.<br>
><br>
><br>
> On 12/08/2015 06:22 PM, Rob Stewart wrote:<br>
><br>
> Are the following two programs equivalent with respect to the strictness<br>
> of `readFile`?<br>
><br>
> --8<---------------cut here---------------start------------->8---<br>
> {-# LANGUAGE BangPatterns #-}<br>
><br>
> module Main where<br>
><br>
> main = do<br>
> !contents <- readFile "foo.txt"<br>
> print contents<br>
> --8<---------------cut here---------------end--------------->8---<br>
><br>
> And:<br>
><br>
> --8<---------------cut here---------------start------------->8---<br>
> {-# LANGAUGE Strict #-}<br>
><br>
> module Main where<br>
><br>
> main = do<br>
> contents <- readFile "foo.txt"<br>
> print contents<br>
> --8<---------------cut here---------------end--------------->8---<br>
><br>
> The documentation on "Strict-by-default pattern bindings" gives<br>
> let/where binding as an example, but there is not a monadic bind example.<br>
> <a href="http://downloads.haskell.org/~ghc/master/users-guide/glasgow_exts.html#strict-by-default-pattern-bindings" rel="noreferrer" target="_blank">http://downloads.haskell.org/~ghc/master/users-guide/glasgow_exts.html#strict-by-default-pattern-bindings</a><br>
><br>
> Inspecting GHC Core for these two programs suggests that<br>
><br>
> !contents <- readFile "foo.txt"<br>
><br>
> is not equivalent to (with Strict enabled):<br>
><br>
> contents <- readFile "foo.txt"<br>
><br>
> Here's core using BangPatterns:<br>
><br>
> (readFile (unpackCString# "foo.txt"#))<br>
> (\ (contents_asg :: String) -><br>
> case contents_asg of contents1_Xsk { __DEFAULT -><br>
> print @ String $dShow_rYy contents1_Xsk<br>
> })<br>
><br>
> Here's core using Strict:<br>
><br>
> (readFile (unpackCString# "foo.txt"#))<br>
> (\ (contents_asg :: String) -><br>
> print @ String $dShow_rYv contents_asg)<br>
><br>
> Does this core align with the design of the Strict extension?<br>
><br>
> If it does, are users going to understand that using Strict is going to<br>
> make let/where bindings strict, but is not going to make <- or >>=<br>
> bindings strict?<br>
><br>
> --<br>
> Rob Stewart<br>
><br>
><br>
> _______________________________________________<br>
> ghc-devs mailing list<br>
> <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> ghc-devs mailing list<br>
> <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
><br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</div></div></blockquote></div><br></div>