module Control.Monad.ST.Persistent.Internal where
import Control.Applicative (Applicative)
import Control.Lens
import Control.Monad.State.Strict
import Data.IntMap
import GHC.Base
data Heap = Heap { _heap :: IntMap Any, _next :: Int }
heap :: Lens' Heap (IntMap Any)
heap _f_a1T2 (Heap __heap'_a1T3 __next_a1T5)
= ((\ __heap_a1T4 -> Heap __heap_a1T4 __next_a1T5)
`fmap` (_f_a1T2 __heap'_a1T3))
next :: Lens' Heap Int
next _f_a1T6 (Heap __heap_a1T7 __next'_a1T8)
= ((\ __next_a1T9 -> Heap __heap_a1T7 __next_a1T9)
`fmap` (_f_a1T6 __next'_a1T8))
emptyHeap :: Heap
emptyHeap = Heap { _heap = empty, _next = minBound }
newtype ST s a = ST (State Heap a)
deriving (Functor, Applicative, Monad)
runST :: (forall s. ST s a) -> a
runST (ST c) = evalState c emptyHeap
newtype STT s m a = STT (StateT Heap m a)
deriving (Functor, Applicative, Monad, MonadIO)
runSTT :: Monad m => (forall s. STT s m a) -> m a
runSTT (STT c) = evalStateT c emptyHeap