Copyright | (c) Sven Panne 2009 (c) HATTORI,HIROKI 2014 |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | HATTORI, HIROKI <seagull.kamome@gmail.com> |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Data.StateVarがIO専用なのが気にくわないので変換できるようにしただけ
- class HasGetter g m | g -> m where
- get :: g a -> m a
- data GettableStateVar m a
- makeGettableStateVar :: m a -> GettableStateVar m a
- class HasSetter s m where
- ($=) :: s a -> a -> m ()
- data SettableStateVar m a
- makeSettableStateVar :: (a -> m ()) -> SettableStateVar m a
- data StateVar m a
- makeStateVar :: m a -> (a -> m ()) -> StateVar m a
- makePtrVar :: (MonadIO m, Storable a) => Ptr a -> StateVar m a
- ($~) :: (Monad m, HasGetter v m, HasSetter v m) => v a -> (a -> a) -> m ()
- ($=!) :: (Monad m, HasSetter s m) => s a -> a -> m ()
- ($~!) :: (Monad m, HasGetter v m, HasSetter v m) => v a -> (a -> a) -> m ()
- (&) :: s -> (s -> t) -> t
- (^=) :: HasSetter g m => (s -> g a) -> a -> s -> m ()
- (^~) :: (Monad m, HasGetter g m, HasSetter g m) => (s -> g a) -> (a -> a) -> s -> m ()
- (^=!) :: (Monad m, HasSetter g m) => (s -> g a) -> a -> s -> m ()
- (^~!) :: (Monad m, HasGetter g m, HasSetter g m) => (s -> g a) -> (a -> a) -> s -> m ()
- (^.) :: (Monad m, HasGetter g m, HasGetter h m) => (s -> g a) -> (a -> h b) -> s -> GettableStateVar m b
- (@=) :: (Monad m, MonadTrans n, MonadReader s (n m), HasSetter g m) => (s -> g a) -> a -> n m ()
Readable State Variables
data GettableStateVar m a Source
A concrete implementation of a read-only state variable, carrying an IO action to read the value.
HasGetter (GettableStateVar m) m |
makeGettableStateVar :: m a -> GettableStateVar m a Source
Construct a GettableStateVar
from an IO action.
Writable State Variables
data SettableStateVar m a Source
A concrete implementation of a write-only state variable, carrying an IO action to write the new value.
HasSetter (SettableStateVar m) m |
makeSettableStateVar :: (a -> m ()) -> SettableStateVar m a Source
Construct a SettableStateVar
from an IO action.
General State Variables
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.
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.
(^~) :: (Monad m, HasGetter g m, HasSetter g m) => (s -> g a) -> (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