module Data.Vault.ST.LAZINESS (
Vault, Key,
empty, newKey, lookup, insert, adjust, delete, union,
Locker,
lock, unlock,
) where
import Data.Monoid (Monoid(..))
import Prelude hiding (lookup)
import Control.Applicative hiding (empty)
import Control.Monad.ST
import Control.Monad.ST.Unsafe as STUnsafe
import Data.Unique.Really
#if UseGHC
#include "backends/GHC.hs"
#else
#include "backends/IORef.hs"
#endif
instance Monoid (Vault s) where
mempty = empty
mappend = union
empty :: Vault s
empty = Vault Map.empty
newKey :: ST s (Key s a)
lookup :: Key s a -> Vault s -> Maybe a
insert :: Key s a -> a -> Vault s -> Vault s
adjust :: (a -> a) -> Key s a -> Vault s -> Vault s
delete :: Key s a -> Vault s -> Vault s
union :: Vault s -> Vault s -> Vault s
union (Vault m) (Vault m') = Vault $ Map.union m m'
lock :: Key s a -> a -> Locker s
unlock :: Key s a -> Locker s -> Maybe a