[GHC] #15349: fixST is a bit wrong

GHC ghc-devs at haskell.org
Mon Jul 9 16:57:26 UTC 2018


#15349: fixST is a bit wrong
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  dfeuer
            Type:  bug               |               Status:  new
        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):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 The only alternative I see for now is to use `noDuplicate#` to fix up the
 implementation, like maybe

 {{{#!hs
 fixST :: (a -> ST s a) -> ST s a
 fixST k = ST $ \ s ->
     let ans       = liftST (noDuplicate >> k r) s
         STret _ r = ans
     in
     case ans of STret s' x -> (# s', x #)
 }}}

 That implementation is also available for `fixIO`, of course. I don't have
 a terribly good sense of how it would compare.

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


More information about the ghc-tickets mailing list