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

-- | a persistent store for values of arbitrary types
--   
--   A vault is a persistent store for values of arbitrary types.
--   It's like having first-class access to the storage space behind
--   IORefs.
--   
--   The data structure is analogous to a bank vault, where you can access
--   different bank boxes with different keys; hence the name.
--   
--   Also provided is a locker type, representing a store for a
--   single element.
--   
--   Changelog:
--   
--   
--   
- 0.3.0.2 - Fix tarball.
--   
- 0.3.0.1 - Use CPP to reduce code duplication.
--   
- 0.3.0.0 - Split modules into Lazy and Strict variants, no default
--   choice. Add Hashable instance to Data.Unique.Really for all
--   implementations.
--   
@package vault
@version 0.3.0.2

-- | An abstract interface to a unique symbol generator.
module Data.Unique.Really

-- | An abstract unique value. Values of type Unique may be compared
--   for equality and hashed into Int.
--   
--   Note: Unlike the symbols from Data.Unique, the symbols from
--   this module do not become equal after reloads in the GHC interpreter!
data Unique

-- | Creates a new object of type Unique. The value returned will
--   not compare equal to any other value of type Unique returned by
--   previous calls to newUnique. There is no limit on the number of
--   times you may call this function.
newUnique :: IO Unique

-- | Hashes a Unique into an Int. Two Uniques may hash to the
--   same value, although in practice this is unlikely. The Int
--   returned makes a good hash key.
hashUnique :: Unique -> Int
instance Eq Unique
instance Hashable Unique

-- | A persistent store for values of arbitrary types. Variant for the
--   ST monad.
--   
--   The Vault type in this module is strict in both keys and
--   values.
module Data.Vault.ST.Strict
data Vault s
data Key s a

-- | The empty vault.
empty :: Vault s

-- | Create a new key for use with a vault.
newKey :: ST s (Key s a)

-- | Lookup the value of a key in the vault.
lookup :: Key s a -> Vault s -> Maybe a

-- | Insert a value for a given key. Overwrites any previous value.
insert :: Key s a -> a -> Vault s -> Vault s

-- | Adjust the value for a given key if it's present in the vault.
adjust :: (a -> a) -> Key s a -> Vault s -> Vault s

-- | Delete a key from the vault.
delete :: Key s a -> Vault s -> Vault s

-- | Merge two vaults (left-biased).
union :: Vault s -> Vault s -> Vault s
data Locker s

-- | Put a single value into a Locker.
lock :: Key s a -> a -> Locker s

-- | Retrieve the value from the Locker.
unlock :: Key s a -> Locker s -> Maybe a
instance Monoid (Vault s)

-- | A persistent store for values of arbitrary types.
--   
--   The Vault type in this module is strict in both keys and
--   values.
module Data.Vault.Strict

-- | 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 = Vault RealWorld

-- | Keys for the vault.
type Key = Key RealWorld

-- | The empty vault.
empty :: Vault

-- | Create a new key for use with a vault.
newKey :: IO (Key a)

-- | Lookup the value of a key in the vault.
lookup :: Key a -> Vault -> Maybe a

-- | Insert a value for a given key. Overwrites any previous value.
insert :: Key a -> a -> Vault -> Vault

-- | Adjust the value for a given key if it's present in the vault.
adjust :: (a -> a) -> Key a -> Vault -> Vault

-- | Delete a key from the vault.
delete :: Key a -> Vault -> Vault

-- | Merge two vaults (left-biased).
union :: Vault -> Vault -> Vault

-- | A persistent store for a single value.
type Locker = Locker RealWorld

-- | Put a single value into a Locker.
lock :: Key a -> a -> Locker

-- | Retrieve the value from the Locker.
unlock :: Key a -> Locker -> Maybe a

-- | A persistent store for values of arbitrary types. Variant for the
--   ST monad.
--   
--   The Vault type in this module is strict in the keys but lazy in
--   the values.
module Data.Vault.ST.Lazy
data Vault s
data Key s a

-- | The empty vault.
empty :: Vault s

-- | Create a new key for use with a vault.
newKey :: ST s (Key s a)

-- | Lookup the value of a key in the vault.
lookup :: Key s a -> Vault s -> Maybe a

-- | Insert a value for a given key. Overwrites any previous value.
insert :: Key s a -> a -> Vault s -> Vault s

-- | Adjust the value for a given key if it's present in the vault.
adjust :: (a -> a) -> Key s a -> Vault s -> Vault s

-- | Delete a key from the vault.
delete :: Key s a -> Vault s -> Vault s

-- | Merge two vaults (left-biased).
union :: Vault s -> Vault s -> Vault s
data Locker s

-- | Put a single value into a Locker.
lock :: Key s a -> a -> Locker s

-- | Retrieve the value from the Locker.
unlock :: Key s a -> Locker s -> Maybe a
instance Monoid (Vault s)

-- | A persistent store for values of arbitrary types.
--   
--   The Vault type in this module is strict in the keys but lazy in
--   the values.
module Data.Vault.Lazy

-- | 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 = Vault RealWorld

-- | Keys for the vault.
type Key = Key RealWorld

-- | The empty vault.
empty :: Vault

-- | Create a new key for use with a vault.
newKey :: IO (Key a)

-- | Lookup the value of a key in the vault.
lookup :: Key a -> Vault -> Maybe a

-- | Insert a value for a given key. Overwrites any previous value.
insert :: Key a -> a -> Vault -> Vault

-- | Adjust the value for a given key if it's present in the vault.
adjust :: (a -> a) -> Key a -> Vault -> Vault

-- | Delete a key from the vault.
delete :: Key a -> Vault -> Vault

-- | Merge two vaults (left-biased).
union :: Vault -> Vault -> Vault

-- | A persistent store for a single value.
type Locker = Locker RealWorld

-- | Put a single value into a Locker.
lock :: Key a -> a -> Locker

-- | Retrieve the value from the Locker.
unlock :: Key a -> Locker -> Maybe a
