StateVar-transformer-1.0.0.0: State variables
Copyright(c) Sven Panne 2009
(c) HATTORIHIROKI 2014
LicenseBSD-style (see the file LICENSE)
MaintainerHATTORI, HIROKI <seagull.kamome@gmail.com>
Stabilitystable
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Data.StateVar.Trans

Description

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

Synopsis

Readable State Variables

class HasGetter (g :: Type -> Type) (m :: Type -> Type) | g -> m where Source #

The class of all readable state variables.

Methods

get :: g a -> m a Source #

Read the value of a state variable.

Instances

Instances details
HasGetter TVar STM Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

get :: TVar a -> STM a Source #

HasGetter IORef IO Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

get :: IORef a -> IO a Source #

HasGetter (GettableStateVar m) m Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

get :: GettableStateVar m a -> m a Source #

HasGetter (StateVar m) m Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

get :: StateVar m a -> m a Source #

HasGetter (STRef s) (ST s) Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

get :: STRef s a -> ST s a Source #

data GettableStateVar (m :: Type -> Type) a Source #

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

Instances

Instances details
HasGetter (GettableStateVar m) m Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

get :: GettableStateVar m a -> m a Source #

makeGettableStateVar :: m a -> GettableStateVar m a Source #

Construct a GettableStateVar from an IO action.

Writable State Variables

class HasSetter (s :: Type -> Type) (m :: Type -> Type) where Source #

The class of all writable state variables.

Methods

($=) :: s a -> a -> m () infixr 2 Source #

Write a new value into a state variable.

Instances

Instances details
HasSetter TVar STM Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

($=) :: TVar a -> a -> STM () Source #

HasSetter IORef IO Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

($=) :: IORef a -> a -> IO () Source #

HasSetter (SettableStateVar m) m Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

($=) :: SettableStateVar m a -> a -> m () Source #

HasSetter (StateVar m) m Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

($=) :: StateVar m a -> a -> m () Source #

HasSetter (STRef s) (ST s) Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

($=) :: STRef s a -> a -> ST s () Source #

data SettableStateVar (m :: Type -> Type) a Source #

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

Instances

Instances details
HasSetter (SettableStateVar m) m Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

($=) :: SettableStateVar m a -> a -> m () Source #

makeSettableStateVar :: (a -> m ()) -> SettableStateVar m a Source #

Construct a SettableStateVar from an IO action.

General State Variables

data StateVar (m :: Type -> Type) 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

Instances details
HasGetter (StateVar m) m Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

get :: StateVar m a -> m a Source #

HasSetter (StateVar m) m Source # 
Instance details

Defined in Data.StateVar.Trans

Methods

($=) :: StateVar m a -> a -> m () Source #

makeStateVar :: m a -> (a -> m ()) -> StateVar m a Source #

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

makePtrVar :: forall (m :: Type -> Type) a. (MonadIO m, Storable a) => Ptr a -> StateVar m a Source #

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) -> t Source #

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

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

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

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

(^.) :: forall (m :: Type -> Type) g h s a b. (Monad m, HasGetter g m, HasGetter h m) => (s -> g a) -> (a -> h b) -> s -> GettableStateVar m b infixl 8 Source #

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