{-----------------------------------------------------------------------------
vault
------------------------------------------------------------------------------}{-# LANGUAGE CPP #-}moduleData.Vault.ST(-- * Synopsis-- | A persistent store for values of arbitrary types.-- Variant for the 'ST' monad.-- * VaultVault,Key,empty,newKey,lookup,insert,adjust,delete,union,-- * LockerLocker,lock,unlock,)whereimportData.Monoid(Monoid(..))importPreludehiding(lookup)importControl.Monad.ST{-
The GHC-specific implementation uses unsafeCoerce
for reasons of efficiency.
See http://apfelmus.nfshost.com/blog/2011/09/04-vault.html for the second implementation that doesn't need to
bypass the type checker.
-}#if UseGHCimportqualifiedData.Vault.ST_GHCasST#elseimportqualifiedData.Vault.ST_PureasST#endif{-----------------------------------------------------------------------------
Vault
------------------------------------------------------------------------------}-- | A persistent store for values of arbitrary types.-- -- This variant is the simplest and creates keys in the 'IO' monad.-- See the module "Data.Vault.ST" if you want to use it with the 'ST' monad instead.---- > type Vault :: * -> *-- > instance Monoid VaulttypeVault=ST.VaultinstanceMonoid(ST.Vaults)wheremempty=emptymappend=union-- | Keys for the vault.---- > type Key :: * -> * -> *typeKey=ST.Key-- | The empty vault.empty::Vaultsempty=ST.empty-- | Create a new key for use with a vault.newKey::STs(Keysa)newKey=ST.newKey-- | Lookup the value of a key in the vault.lookup::Keysa->Vaults->Maybealookup=ST.lookup-- | Insert a value for a given key. Overwrites any previous value.insert::Keysa->a->Vaults->Vaultsinsert=ST.insert-- | Adjust the value for a given key if it's present in the vault.adjust::(a->a)->Keysa->Vaults->Vaultsadjust=ST.adjust-- | Delete a key from the vault.delete::Keysa->Vaults->Vaultsdelete=ST.delete-- | Merge two vaults (left-biased).union::Vaults->Vaults->Vaultsunion=ST.union{-----------------------------------------------------------------------------
Locker
------------------------------------------------------------------------------}-- | A persistent store for a single value.---- > type Locker :: * -> *typeLocker=ST.Locker-- | Put a single value into a 'Locker'.lock::Keysa->a->Lockerslock=ST.lock-- | Retrieve the value from the 'Locker'.unlock::Keysa->Lockers->Maybeaunlock=ST.unlock