{-# LANGUAGE MagicHash, UnboxedTuples #-} module Data.RangeMin.Cartesian.STInt (STInt, toSTInt, runSTInt) where import GHC.ST import GHC.Exts newtype STInt s = STInt {execSTInt :: State# s -> (# State# s, Int# #)} {-# INLINE toSTInt #-} toSTInt :: ST s Int -> STInt s toSTInt (ST m) = STInt $ \ s# -> case m s# of (# s'#, I# i# #) -> (# s'#, i# #) runSTInt :: STInt s -> ST s Int runSTInt (STInt m) = ST $ \ s# -> case m s# of (# s'#, i# #) -> (# s'#, I# i# #)