| Copyright | (c) Sven Panne 2009 (c) HATTORIHIROKI 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.Trans
Description
Data.StateVarがIO専用なのが気にくわないので変換できるようにしただけ
Synopsis
- class HasGetter (g :: Type -> Type) (m :: Type -> Type) | g -> m where
- get :: g a -> m a
- data GettableStateVar (m :: Type -> Type) a
- makeGettableStateVar :: m a -> GettableStateVar m a
- class HasSetter (s :: Type -> Type) (m :: Type -> Type) where
- ($=) :: s a -> a -> m ()
- data SettableStateVar (m :: Type -> Type) a
- makeSettableStateVar :: (a -> m ()) -> SettableStateVar m a
- data StateVar (m :: Type -> Type) a
- makeStateVar :: m a -> (a -> m ()) -> StateVar m a
- makePtrVar :: forall (m :: Type -> Type) a. (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 ()
- (^.) :: 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
- (@=) :: 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 ()
Readable State Variables
class HasGetter (g :: Type -> Type) (m :: Type -> Type) | g -> m where Source #
The class of all readable state variables.
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
| HasGetter (GettableStateVar m) m Source # | |
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.
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
| HasSetter (SettableStateVar m) m Source # | |
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.
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.
(^~) :: (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 #
(^.) :: 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 #