[GHC] #11760: runST with lazy blackholing breaks referential transparency

GHC ghc-devs at haskell.org
Thu Oct 13 08:59:19 UTC 2016


#11760: runST with lazy blackholing breaks referential transparency
-------------------------------------+-------------------------------------
        Reporter:  Yuras             |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 I agree with Neil here.

 But is it just `runST`?  Every time we build a thunk whose evaluation will
 mutate state, we must ensure that thunk can be evaluated at most once (no-
 duplicate).  And doesn't every use of `bind` in the lazy ST world have
 that property?

 From `Control.Monad.Lazy.ST.Lazy.Imp`:
 {{{
         (ST m) >>= k
          = ST $ \ s ->
            let
              (r,new_s) = m s
              ST k_a = k r
            in
            k_a new_s
 }}}
 That `m s` thunk must be evaluated at most once.

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


More information about the ghc-tickets mailing list