StateVar-transformer-1.0.0.0: State variables

Portabilityportable
Stabilitystable
MaintainerHATTORI, HIROKI <seagull.kamome@gmail.com>
Safe HaskellNone

Data.StateVar.Trans

Contents

Description

Data.StateVarがIO専用なのが気にくわないので変換できるようだけ

Synopsis

Readable State Variables

class HasGetter g m | g -> m whereSource

The class of all readable state variables.

Methods

get :: g a -> m aSource

Read the value of a state variable.

data GettableStateVar m a Source

A concrete implementation of a read-only state variable, carrying an IO action to read the value.

Instances

makeGettableStateVar :: m a -> GettableStateVar m aSource

Construct a GettableStateVar from an IO action.

Writable State Variables

class HasSetter s m whereSource

The class of all writable state variables.

Methods

($=) :: s a -> a -> m ()Source

Write a new value into a state variable.

data SettableStateVar m a Source

A concrete implementation of a write-only state variable, carrying an IO action to write the new value.

Instances

makeSettableStateVar :: (a -> m ()) -> SettableStateVar m aSource

Construct a SettableStateVar from an IO action.

General State Variables

data StateVar m a Source

A concrete implementation of a readable and writable state variable, carrying one IO action to read the value and another IO action to write the new value.

Instances

makeStateVar :: m a -> (a -> m ()) -> StateVar m aSource

Construct a StateVar from two IO actions, one for reading and one for writing.

Utility Functions

($~) :: (Monad m, HasGetter v m, HasSetter v m) => v a -> (a -> a) -> m ()Source

A modificator convenience function, transforming the contents of a state variable with a given funtion.

($=!) :: (Monad m, HasSetter s m) => s a -> a -> m ()Source

A variant of $= which is strict in the value to be set.

($~!) :: (Monad m, HasGetter v m, HasSetter v m) => v a -> (a -> a) -> m ()Source

A variant of $~ which is strict in the transformed value.

(&) :: s -> (s -> t) -> tSource

(^=) :: HasSetter g m => (s -> g a) -> a -> s -> m ()Source

(^~) :: (Monad m, HasGetter g m, HasSetter g m) => (s -> g a) -> (a -> a) -> s -> m ()Source

(^=!) :: (Monad m, HasSetter g m) => (s -> g a) -> a -> s -> m ()Source

(^~!) :: (Monad m, HasGetter g m, HasSetter g m) => (s -> g a) -> (a -> a) -> s -> m ()Source

(^.) :: (Monad m, HasGetter g m, HasGetter h m) => (s -> g a) -> (a -> h b) -> s -> GettableStateVar m bSource

(@=) :: (Monad m, MonadTrans n, MonadReader s (n m), HasSetter g m) => (s -> g a) -> a -> n m ()Source