netwire-5.0.3: Functional reactive programming library

Copyright | (c) 2013 Ertugrul Soeylemez
License | BSD3
Maintainer | Ertugrul Soeylemez <es@ertes.de>
Safe Haskell | Safe-Inferred
Language | Haskell2010

Control.Wire.Session

Contents

- State delta types
  - Wires with time

Description

Synopsis

- class (Monoid s, Real t) => HasTime t s | s -> t where
  - dtime :: s -> t
- newtype Session (m :: Type -> Type) s = Session {
  - stepSession :: m (s, Session m s)
  }
- data Timed t s = Timed t s
- clockSession :: forall (m :: Type -> Type) s. MonadIO m => Session m (s -> Timed NominalDiffTime s)
- clockSession_ :: forall (m :: Type -> Type). (Applicative m, MonadIO m) => Session m (Timed NominalDiffTime ())
- countSession :: forall (m :: Type -> Type) t s. Applicative m => t -> Session m (s -> Timed t s)
- countSession_ :: forall (m :: Type -> Type) t. Applicative m => t -> Session m (Timed t ())

# State delta types

class (Monoid s, Real t) => HasTime t s | s -> t where Source #

State delta types with time deltas.

Methods

dtime :: s -> t Source #

Extract the current time delta.

#### Instances

Instances details

(Semigroup s, Monoid s, Real t) => HasTime t (Timed t s) Source # |
Instance details Defined in Control.Wire.Session Methods dtime :: Timed t s -> t Source #

newtype Session (m :: Type -> Type) s Source #

State delta generators as required for wire sessions, most notably to generate time deltas. These are mini-wires with the sole purpose of generating these deltas.

Constructors

Session |

Fields

- stepSession :: m (s, Session m s)

#### Instances

Instances details

Applicative m => Applicative (Session m) Source # |
Instance details Defined in Control.Wire.Session Methods pure :: a -> Session m a Source # (<*>) :: Session m (a -> b) -> Session m a -> Session m b Source # liftA2 :: (a -> b -> c) -> Session m a -> Session m b -> Session m c Source # (*>) :: Session m a -> Session m b -> Session m b Source # (<*) :: Session m a -> Session m b -> Session m a Source #
Functor m => Functor (Session m) Source # |
Instance details Defined in Control.Wire.Session Methods fmap :: (a -> b) -> Session m a -> Session m b Source # (<$) :: a -> Session m b -> Session m a Source #

## Wires with time

data Timed t s Source #

This state delta type denotes time deltas. This is necessary for most FRP applications.

Constructors

Timed t s |

#### Instances

Instances details

(Semigroup s, Monoid s, Real t) => HasTime t (Timed t s) Source # |
Instance details Defined in Control.Wire.Session Methods dtime :: Timed t s -> t Source #
Functor (Timed t) Source # |
Instance details Defined in Control.Wire.Session Methods fmap :: (a -> b) -> Timed t a -> Timed t b Source # (<$) :: a -> Timed t b -> Timed t a Source #
Foldable (Timed t) Source # |

Instance details

Defined in Control.Wire.Session

Methods

fold :: Monoid m => Timed t m -> m Source #

foldMap :: Monoid m => (a -> m) -> Timed t a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Timed t a -> m Source #

foldr :: (a -> b -> b) -> b -> Timed t a -> b Source #

foldr' :: (a -> b -> b) -> b -> Timed t a -> b Source #

foldl :: (b -> a -> b) -> b -> Timed t a -> b Source #

foldl' :: (b -> a -> b) -> b -> Timed t a -> b Source #

foldr1 :: (a -> a -> a) -> Timed t a -> a Source #

foldl1 :: (a -> a -> a) -> Timed t a -> a Source #

toList :: Timed t a -> [a] Source #

null :: Timed t a -> Bool Source #

length :: Timed t a -> Int Source #

elem :: Eq a => a -> Timed t a -> Bool Source #

maximum :: Ord a => Timed t a -> a Source #

minimum :: Ord a => Timed t a -> a Source #

sum :: Num a => Timed t a -> a Source #

product :: Num a => Timed t a -> a Source #

Traversable (Timed t) Source # |
Instance details Defined in Control.Wire.Session Methods traverse :: Applicative f => (a -> f b) -> Timed t a -> f (Timed t b) Source # sequenceA :: Applicative f => Timed t (f a) -> f (Timed t a) Source # mapM :: Monad m => (a -> m b) -> Timed t a -> m (Timed t b) Source # sequence :: Monad m => Timed t (m a) -> m (Timed t a) Source #
(Semigroup s, Monoid s, Num t) => Monoid (Timed t s) Source # |
Instance details Defined in Control.Wire.Session Methods mempty :: Timed t s Source # mappend :: Timed t s -> Timed t s -> Timed t s Source # mconcat :: [Timed t s] -> Timed t s Source #
(Semigroup s, Num t) => Semigroup (Timed t s) Source # |
Instance details Defined in Control.Wire.Session Methods (<>) :: Timed t s -> Timed t s -> Timed t s Source # sconcat :: NonEmpty (Timed t s) -> Timed t s Source # stimes :: Integral b => b -> Timed t s -> Timed t s Source #
(Data t, Data s) => Data (Timed t s) Source # |

Instance details

Defined in Control.Wire.Session

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Timed t s -> c (Timed t s) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Timed t s) Source #

toConstr :: Timed t s -> Constr Source #

dataTypeOf :: Timed t s -> DataType Source #

dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Timed t s)) Source #

dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Timed t s)) Source #

gmapT :: (forall b. Data b => b -> b) -> Timed t s -> Timed t s Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Timed t s -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Timed t s -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Timed t s -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Timed t s -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Timed t s -> m (Timed t s) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Timed t s -> m (Timed t s) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Timed t s -> m (Timed t s) Source #

(Read t, Read s) => Read (Timed t s) Source # |
Instance details Defined in Control.Wire.Session Methods readsPrec :: Int -> ReadS (Timed t s) Source # readList :: ReadS [Timed t s] Source # readPrec :: ReadPrec (Timed t s) Source # readListPrec :: ReadPrec [Timed t s] Source #
(Show t, Show s) => Show (Timed t s) Source # |
Instance details Defined in Control.Wire.Session Methods showsPrec :: Int -> Timed t s -> ShowS Source # show :: Timed t s -> String Source # showList :: [Timed t s] -> ShowS Source #
(Eq t, Eq s) => Eq (Timed t s) Source # |
Instance details Defined in Control.Wire.Session Methods (==) :: Timed t s -> Timed t s -> Bool Source # (/=) :: Timed t s -> Timed t s -> Bool Source #
(Ord t, Ord s) => Ord (Timed t s) Source # |

Instance details

Defined in Control.Wire.Session

Methods

compare :: Timed t s -> Timed t s -> Ordering Source #

(<) :: Timed t s -> Timed t s -> Bool Source #

(<=) :: Timed t s -> Timed t s -> Bool Source #

(>) :: Timed t s -> Timed t s -> Bool Source #

(>=) :: Timed t s -> Timed t s -> Bool Source #

max :: Timed t s -> Timed t s -> Timed t s Source #

min :: Timed t s -> Timed t s -> Timed t s Source #

clockSession :: forall (m :: Type -> Type) s. MonadIO m => Session m (s -> Timed NominalDiffTime s) Source #

State delta generator for a real time clock.

clockSession_ :: forall (m :: Type -> Type). (Applicative m, MonadIO m) => Session m (Timed NominalDiffTime ()) Source #

Non-extending version of `clockSession`.

countSession Source #

Arguments

:: forall (m :: Type -> Type) t s. Applicative m |
=> t | Increment size.
-> Session m (s -> Timed t s) |

State delta generator for a simple counting clock. Denotes a fixed framerate. This is likely more useful than `clockSession` for simulations and real-time games.

countSession_ :: forall (m :: Type -> Type) t. Applicative m => t -> Session m (Timed t ()) Source #

Non-extending version of `countSession`.