Data.Vault.ST.Strict

vault-0.3.1.5: a persistent store for values of arbitrary types

Safe Haskell | None
Language | Haskell2010

Data.Vault.ST.Strict

Contents

- Vault
- Locker

Description

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.

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
- data Locker s
- lock :: Key s a -> a -> Locker s
- unlock :: Key s a -> Locker s -> Maybe a

# Vault

data Vault s #

#### Instances

Instances details

Monoid (Vault s) # |
Instance details Defined in Data.Vault.ST.Strict Methods mempty :: Vault s # mappend :: Vault s -> Vault s -> Vault s # mconcat :: [Vault s] -> Vault s #
Semigroup (Vault s) # |
Instance details Defined in Data.Vault.ST.Strict Methods (<>) :: Vault s -> Vault s -> Vault s # sconcat :: NonEmpty (Vault s) -> Vault s # stimes :: Integral b => b -> Vault s -> Vault s #

data Key s a #

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).

# Locker

data Locker s #

lock :: Key s a -> a -> Locker s #

Put a single value into a `Locker`.

unlock :: Key s a -> Locker s -> Maybe a #

Retrieve the value from the `Locker`.