chatty-utils-0.7.3.5: 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. Not recommended. Use IORef, STRef or the like. Really.

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

Instances details
Eq (Atom a) Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

(==) :: Atom a -> Atom a -> Bool #

(/=) :: Atom a -> Atom a -> Bool #

Ord (Atom a) Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

compare :: Atom a -> Atom a -> Ordering #

(<) :: Atom a -> Atom a -> Bool #

(<=) :: Atom a -> Atom a -> Bool #

(>) :: Atom a -> Atom a -> Bool #

(>=) :: Atom a -> Atom a -> Bool #

max :: Atom a -> Atom a -> Atom a #

min :: Atom a -> Atom a -> Atom a #

newtype Container Source #

Constructors

Container () 

newtype AtomStoreT m a Source #

The storage monad

Constructors

AtomStore 

Fields

Instances

Instances details
MonadTrans AtomStoreT Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

lift :: Monad m => m a -> AtomStoreT m a #

Monad m => Monad (AtomStoreT m) Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

(>>=) :: AtomStoreT m a -> (a -> AtomStoreT m b) -> AtomStoreT m b #

(>>) :: AtomStoreT m a -> AtomStoreT m b -> AtomStoreT m b #

return :: a -> AtomStoreT m a #

Functor m => Functor (AtomStoreT m) Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

fmap :: (a -> b) -> AtomStoreT m a -> AtomStoreT m b #

(<$) :: a -> AtomStoreT m b -> AtomStoreT m a #

(Functor m, Monad m) => Applicative (AtomStoreT m) Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

pure :: a -> AtomStoreT m a #

(<*>) :: AtomStoreT m (a -> b) -> AtomStoreT m a -> AtomStoreT m b #

liftA2 :: (a -> b -> c) -> AtomStoreT m a -> AtomStoreT m b -> AtomStoreT m c #

(*>) :: AtomStoreT m a -> AtomStoreT m b -> AtomStoreT m b #

(<*) :: AtomStoreT m a -> AtomStoreT m b -> AtomStoreT m a #

MonadIO m => MonadIO (AtomStoreT m) Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

liftIO :: IO a -> AtomStoreT m a #

ChCounter m => ChCounter (AtomStoreT m) Source # 
Instance details

Defined in Data.Chatty.Atoms

ChCounter m => ChAtoms (AtomStoreT m) Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

newAtom :: AtomStoreT m (Atom v) Source #

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

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

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

getAtom :: Atom v -> AtomStoreT m v Source #

dispAtom :: Atom v -> AtomStoreT m () Source #

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

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

Instances details
ChCounter m => ChAtoms (AtomStoreT m) Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

newAtom :: AtomStoreT m (Atom v) Source #

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

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

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

getAtom :: Atom v -> AtomStoreT m v Source #

dispAtom :: Atom v -> AtomStoreT m () Source #

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

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

Instances

Instances details
ChAtoms m => Arrow (Redundant m) Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

arr :: (b -> c) -> Redundant m b c #

first :: Redundant m b c -> Redundant m (b, d) (c, d) #

second :: Redundant m b c -> Redundant m (d, b) (d, c) #

(***) :: Redundant m b c -> Redundant m b' c' -> Redundant m (b, b') (c, c') #

(&&&) :: Redundant m b c -> Redundant m b c' -> Redundant m b (c, c') #

ChAtoms m => Category (Redundant m :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Chatty.Atoms

Methods

id :: forall (a :: k). Redundant m a a #

(.) :: forall (b :: k) (c :: k) (a :: k). Redundant m b c -> Redundant m a b -> Redundant m a c #