Data.Vault.ST

vault-0.1.0.0: a typed, persistent store for values of arbitrary types

Safe Haskell | None

Data.Vault.ST

Synopsis

- data Vault s
- data Key s a
- empty :: Vault s
- 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

# Documentation

data Vault s

A typed, persistent store for values of arbitrary types.

This variant has more complex types so that you can create keys in the `ST` monad. See the module Data.Vault if you'd like to use a simpler version with the `IO` monad. You can also use both variants simultaneously; they share a single representation.

Instances

Monoid (Vault s) |

data Key s a

Keys for the vault.

empty :: Vault s

The empty vault.

newKey :: ST s (Key s a)

Create a new key for use with a vault.

lookup :: Key s a -> Vault s -> Maybe a

Lookup the value of a key in the vault.

insert :: Key s a -> a -> Vault s -> Vault s

Insert a value for a given key. Overwrites any previous value.

adjust :: (a -> a) -> Key s a -> Vault s -> Vault s

Adjust the value for a given key if it's present in the vault.

delete :: Key s a -> Vault s -> Vault s

Delete a key from the vault.

union :: Vault s -> Vault s -> Vault s

Merge two vaults (left-biased).