Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 29 lines (24 sloc) 0.918 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
{-# LANGUAGE MagicHash, Rank2Types, UnboxedTuples #-}

-- | This module exports a workaround for this bug:
--
-- http://hackage.haskell.org/trac/ghc/ticket/5916
--
-- Please read the comments in ghc/libraries/base/GHC/ST.lhs to
-- understand what's going on here.
--
-- Code that uses this module should be compiled with -fno-full-laziness
module Data.HashMap.Unsafe
    ( runST
    ) where

import GHC.Base (realWorld#)
import GHC.ST hiding (runST, runSTRep)

-- | Return the value computed by a state transformer computation.
-- The @forall@ ensures that the internal state used by the 'ST'
-- computation is inaccessible to the rest of the program.
runST :: (forall s. ST s a) -> a
runST st = runSTRep (case st of { ST st_rep -> st_rep })
{-# INLINE runST #-}

runSTRep :: (forall s. STRep s a) -> a
runSTRep st_rep = case st_rep realWorld# of
                        (# _, r #) -> r
{-# INLINE [0] runSTRep #-}
Something went wrong with that request. Please try again.