-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Haskell references backed by an IntMap for persistence and reversibility.
--   
--   This library provides support for a persistent version of the
--   <a>Control.Monad.ST.ST</a> monad. Internally, references are backed by
--   a <a>Data.IntMap.IntMap</a>, rather than being mutable variables on
--   the heap. This decreases performance, but can be useful in certain
--   settings, particularly those involving backtracking.
@package persistent-refs
@version 0.4


-- | Mutable references in the persistent <a>ST</a> monad.
module Data.STRef.Persistent
data STRef s a

-- | Get the underlying <a>Int</a> from an <a>STRef</a>. Useful for
--   debugging.
asInt :: STRef s a -> Int

-- | The <a>MonadRef</a> type class abstracts over the details of
--   manipulating references, allowing one to write code that uses
--   references and can operate in any monad that supports reference
--   operations.
class Monad m => MonadRef (r :: * -> *) (m :: * -> *) | m -> r

-- | Create a new reference
newRef :: MonadRef r m => a -> m (r a)

-- | Read the value of a reference
readRef :: MonadRef r m => r a -> m a

-- | Write a new value to a reference
writeRef :: MonadRef r m => r a -> a -> m ()

-- | Mutate the contents of a reference
modifyRef :: MonadRef r m => r a -> (a -> a) -> m ()

-- | Strict version of <a>modifyRef</a>
modifyRef' :: MonadRef r m => r a -> (a -> a) -> m ()
instance GHC.Show.Show (Data.STRef.Persistent.STRef s a)
instance GHC.Classes.Eq (Data.STRef.Persistent.STRef s a)
instance GHC.Base.Monad m => Control.Monad.Ref.MonadRef (Data.STRef.Persistent.STRef s) (Control.Monad.ST.Persistent.Internal.STT s m)


-- | This library provides support for a persistent version of the
--   <a>ST</a> monad. Internally, references are backed by a <a>IntMap</a>,
--   rather than being mutable variables on the heap. This decreases
--   performance, but can be useful in certain settings, particularly those
--   involving backtracking.
module Control.Monad.ST.Persistent

-- | A persistent version of the <a>ST</a> monad.
type ST s = STT s Identity

-- | Run a computation that uses persistent references, and return a pure
--   value. The rank-2 type offers similar guarantees to <a>runST</a>.
runST :: (forall s. ST s a) -> a
data STT s m a

-- | Run a computation that uses persistent references, and return a pure
--   value. The rank-2 type offers similar guarantees to <a>runST</a>.
runSTT :: Monad m => (forall s. STT s m a) -> m a
