chatty-utils-0.7.3.0: Some utilities every serious chatty-based application may need.

Safe HaskellTrustworthy
LanguageHaskell2010

Data.Chatty.Atoms

Description

Provides a variable-storing monad and functions for access

Synopsis

Documentation

data Atom a Source

Phantom type for atom IDs

Constructors

Atom Int 
forall b . FunAtom Int (Atom b) (b -> a) (b -> a -> b) 
forall b c . FunAtom2 Int (Atom b) (Atom c) ((b, c) -> a) ((b, c) -> a -> (b, c)) 

Instances

Eq (Atom a) 
Ord (Atom a) 

newtype Container Source

Constructors

Container () 

newtype AtomStoreT m a Source

The storage monad

Constructors

AtomStore 

Fields

runAtomStoreT :: AVL (Int, Container) -> m (a, AVL (Int, Container))
 

class ChCounter m => ChAtoms m where Source

Typeclass for all atom-storing monads.

Minimal complete definition

putAtom, getAtom, dispAtom

Methods

newAtom :: m (Atom v) Source

Reserve a new atom.

funAtom :: Atom b -> (b -> a) -> (b -> a -> b) -> m (Atom a) Source

Construct a new functional atom.

funAtom2 :: Atom b -> Atom c -> ((b, c) -> a) -> ((b, c) -> a -> (b, c)) -> m (Atom a) Source

Construct a new doubly-source functional atom

putAtom :: Atom v -> v -> m () Source

Save a value for the given atom.

getAtom :: Atom v -> m v Source

Get the value from a given atom.

dispAtom :: Atom v -> m () Source

Dispose the given atom.

cloneAtom :: Atom v -> m (Atom v) Source

Clone the given atom.

Instances

mapAtom :: ChAtoms m => (a -> a) -> Atom a -> m () Source

Run a pure function on atoms.

newtype Redundant m a b Source

Arrow type operating on atoms. Works by cloning the educt, then overwriting the clone. You shouldn't use this inside long-term environments, as massive usage blows up the memory.

Constructors

Redundant 

Fields

runRedundant :: Atom a -> m (Atom b)
 

Instances