[GHC] #11193: Strict extension does not make monadic bindings strict

GHC ghc-devs at haskell.org
Thu Dec 10 15:36:42 UTC 2015


#11193: Strict extension does not make monadic bindings strict
-------------------------------------+-------------------------------------
           Reporter:  robstewartuk   |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.0.1
          Component:  Compiler       |           Version:  7.11
  (CodeGen)                          |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 The following two programs are not equivalent with respect to the
 strictness of `readFile`:

 {{{#!hs
 {-# LANGUAGE BangPatterns #-}

 module Main where

 main = do
   !contents <- readFile "foo.txt"
   print contents
 }}}

 And:

 {{{#!hs
 {-# LANGAUGE Strict #-}

 module Main where

 main = do
   contents <- readFile "foo.txt"
   print contents
 }}}

 Inspecting GHC Core for these two programs suggests that

 {{{#!hs
 !contents <- readFile "foo.txt"
 }}}

 is not equivalent to (with Strict enabled):

 {{{#!hs
 contents <- readFile "foo.txt"
 }}}

 Here's core using '''BangPatterns''':

 {{{
 (readFile (unpackCString# "foo.txt"#))
 (\ (contents_asg :: String) ->
    case contents_asg of contents1_Xsk { __DEFAULT ->
    print @ String $dShow_rYy contents1_Xsk
    })
 }}}

 Here's core using '''Strict''':

 {{{
 (readFile (unpackCString# "foo.txt"#))
 (\ (contents_asg :: String) ->
    print @ String $dShow_rYv contents_asg)
 }}}

 Does this core align with the design of the Strict extension? If it does,
 are users going to understand that using Strict is going to make let/where
 bindings strict, but is not going to make `>>=` bindings strict?

 However, this is likely to just be a bug. At least, Johan Tibell and Adam
 Sandberg Eriksson, the designers and implementers of the `Strict`
 extension, believe this to be a bug:

 > Johan Tibell @ Thu Dec 10 14:34:39 UTC 2015 writes:
 >
 > I believe this is just a bug, since the desugaring ought to be strict in
 the \x.

 https://mail.haskell.org/pipermail/ghc-devs/2015-December/010747.html

 > Adam Sandberg Eriksson @ Thu Dec 10 15:26:17 UTC 2015 writes:
 >
 > I agree that this seems to be a bug. I have a lot to do currently, but
 might be able to look at it sometime during next week.

 https://mail.haskell.org/pipermail/ghc-devs/2015-December/010749.html

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11193>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list