<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    While there's a fundamental difference between (>>=) and
    let-bindings, it might be worth adding to the docs that -XStrict
    only makes let bindings strict.<br>
    <br>
    <div class="moz-cite-prefix">On 12/08/2015 06:22 PM, Rob Stewart
      wrote:<br>
    </div>
    <blockquote
cite="mid:CA+ZOasJ=bw=Ahsakj9KmNxJ-kyoJevAUaUkMikCOhh9_M5azMQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Are the following two programs equivalent with respect to
          the strictness</div>
        <div>of `readFile`?</div>
        <div><br>
        </div>
        <div>--8<---------------cut
          here---------------start------------->8---</div>
        <div>{-# LANGUAGE BangPatterns #-}</div>
        <div><br>
        </div>
        <div>module Main where</div>
        <div><br>
        </div>
        <div>main = do</div>
        <div>  !contents <- readFile "foo.txt"</div>
        <div>  print contents</div>
        <div>--8<---------------cut
          here---------------end--------------->8---</div>
        <div><br>
        </div>
        <div>And:</div>
        <div><br>
        </div>
        <div>--8<---------------cut
          here---------------start------------->8---</div>
        <div>{-# LANGAUGE Strict #-}</div>
        <div><br>
        </div>
        <div>module Main where</div>
        <div><br>
        </div>
        <div>main = do</div>
        <div>  contents <- readFile "foo.txt"</div>
        <div>  print contents</div>
        <div>--8<---------------cut
          here---------------end--------------->8---</div>
        <div><br>
        </div>
        <div>The documentation on "Strict-by-default pattern bindings"
          gives</div>
        <div>let/where binding as an example, but there is not a monadic
          bind example.</div>
        <div><a moz-do-not-send="true"
href="http://downloads.haskell.org/%7Eghc/master/users-guide/glasgow_exts.html#strict-by-default-pattern-bindings">http://downloads.haskell.org/~ghc/master/users-guide/glasgow_exts.html#strict-by-default-pattern-bindings</a></div>
        <div><br>
        </div>
        <div>Inspecting GHC Core for these two programs suggests that</div>
        <div><br>
        </div>
        <div>!contents <- readFile "foo.txt"</div>
        <div><br>
        </div>
        <div>is not equivalent to (with Strict enabled):</div>
        <div><br>
        </div>
        <div>contents <- readFile "foo.txt"</div>
        <div><br>
        </div>
        <div>Here's core using BangPatterns:</div>
        <div><br>
        </div>
        <div>(readFile (unpackCString# "foo.txt"#))</div>
        <div>(\ (contents_asg :: String) -></div>
        <div>   case contents_asg of contents1_Xsk { __DEFAULT -></div>
        <div>   print @ String $dShow_rYy contents1_Xsk</div>
        <div>   })</div>
        <div><br>
        </div>
        <div>Here's core using Strict:</div>
        <div><br>
        </div>
        <div>(readFile (unpackCString# "foo.txt"#))</div>
        <div>(\ (contents_asg :: String) -></div>
        <div>   print @ String $dShow_rYv contents_asg)</div>
        <div><br>
        </div>
        <div>Does this core align with the design of the Strict
          extension?</div>
        <div><br>
        </div>
        <div>If it does, are users going to understand that using Strict
          is going to</div>
        <div>make let/where bindings strict, but is not going to make
          <- or >>=</div>
        <div>bindings strict?</div>
        <div><br>
        </div>
        <div>--</div>
        <div>Rob Stewart</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
ghc-devs mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>