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

Safe Haskell | None
Language | Haskell98

Data.Vault.Strict

Contents

- Vault
- Locker

Description

A persistent store for values of arbitrary types.

The `Vault` type in this module is strict in both keys and values.

Synopsis

- type Vault = Vault RealWorld
- type Key = Key RealWorld
- empty :: Vault
- newKey :: IO (Key a)
- lookup :: Key a -> Vault -> Maybe a
- insert :: Key a -> a -> Vault -> Vault
- adjust :: (a -> a) -> Key a -> Vault -> Vault
- delete :: Key a -> Vault -> Vault
- union :: Vault -> Vault -> Vault
- type Locker = Locker RealWorld
- lock :: Key a -> a -> Locker
- unlock :: Key a -> Locker -> Maybe a

# Vault

type Vault = Vault RealWorld Source #

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 Key = Key RealWorld Source #

Keys for the vault.

empty :: Vault Source #

The empty vault.

newKey :: IO (Key a) Source #

Create a new key for use with a vault.

lookup :: Key a -> Vault -> Maybe a Source #

Lookup the value of a key in the vault.

insert :: Key a -> a -> Vault -> Vault Source #

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

adjust :: (a -> a) -> Key a -> Vault -> Vault Source #

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

delete :: Key a -> Vault -> Vault Source #

Delete a key from the vault.

union :: Vault -> Vault -> Vault Source #

Merge two vaults (left-biased).

# Locker

type Locker = Locker RealWorld Source #

A persistent store for a single value.

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

Put a single value into a `Locker`.

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

Retrieve the value from the `Locker`.