StateVar-transformer-1.0.0.0: State variables

Copyright(c) Sven Panne 2009 (c) HATTORI,HIROKI 2014
LicenseBSD-style (see the file LICENSE)
MaintainerHATTORI, HIROKI <seagull.kamome@gmail.com>
Stabilitystable
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Data.StateVar.Trans

Contents

Description

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

Synopsis

Readable State Variables

class HasGetter g m | 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.

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 a Source

Construct a GettableStateVar from an IO action.

Writable State Variables

class HasSetter s m 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.

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 a Source

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 a Source

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) -> 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

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

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