[GHC] #15349: fixST is a bit wrong

GHC ghc-devs at haskell.org
Tue Jul 10 21:06:45 UTC 2018


#15349: fixST is a bit wrong
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  dfeuer
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Core Libraries    |              Version:  8.5
      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):  Phab:D4948
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 I've put up a differential to fix ''strict'' `ST`. Unfortunately, all my
 attempts thus far to fix ''lazy'' `ST` have been extremely fragile. I
 don't really understand what's going on well enough to see exactly what
 the trouble is, let alone how to fix it. My lazy `ST` test case:

 {{{#!hs
 foo :: ST s Int
 foo = do
   ref <- strictToLazyST (newSTRef True)
   fixST $ \res -> strictToLazyST $ do
     x <- readSTRef ref
     if x
       then do
         writeSTRef ref False
         return $! (res + 5)
       else return 10

 main = print $ runST foo
 }}}

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


More information about the ghc-tickets mailing list