Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The MonadSchedule
class from the monad-schedule
package is the compatibility mechanism between two different clocks.
It implements a concurrency abstraction that allows the clocks to run at the same time, independently.
Several such clocks running together form composite clocks, such as ParallelClock
and SequentialClock
.
This module defines these composite clocks,
and utilities to work with them.
Synopsis
- scheduleList :: (Monad m, MonadSchedule m) => NonEmpty (Automaton m a b) -> Automaton m a (NonEmpty b)
- schedulePair :: (Monad m, MonadSchedule m) => Automaton m a b -> Automaton m a b -> Automaton m a b
- runningSchedule :: (Monad m, MonadSchedule m, Clock m cl1, Clock m cl2, Time cl1 ~ Time cl2) => cl1 -> cl2 -> RunningClock m (Time cl1) (Tag cl1) -> RunningClock m (Time cl2) (Tag cl2) -> RunningClock m (Time cl1) (Either (Tag cl1) (Tag cl2))
- initSchedule :: (Time cl1 ~ Time cl2, Monad m, MonadSchedule m, Clock m cl1, Clock m cl2) => cl1 -> cl2 -> RunningClockInit m (Time cl1) (Either (Tag cl1) (Tag cl2))
- data SequentialClock cl1 cl2 = Time cl1 ~ Time cl2 => SequentialClock {
- sequentialCl1 :: cl1
- sequentialCl2 :: cl2
- type SeqClock cl1 cl2 = SequentialClock cl1 cl2
- data ParallelClock cl1 cl2 = Time cl1 ~ Time cl2 => ParallelClock {
- parallelCl1 :: cl1
- parallelCl2 :: cl2
- type ParClock cl1 cl2 = ParallelClock cl1 cl2
- type family In cl where ...
- type family Out cl where ...
- data LastTime cl where
- SequentialLastTime :: LastTime cl1 -> LastTime cl2 -> LastTime (SequentialClock cl1 cl2)
- ParallelLastTime :: LastTime cl1 -> LastTime cl2 -> LastTime (ParallelClock cl1 cl2)
- LeafLastTime :: Time cl -> LastTime cl
- data ParClockInclusion clS cl where
- ParClockInL :: ParClockInclusion (ParallelClock clL clR) cl -> ParClockInclusion clL cl
- ParClockInR :: ParClockInclusion (ParallelClock clL clR) cl -> ParClockInclusion clR cl
- ParClockRefl :: ParClockInclusion cl cl
- parClockTagInclusion :: ParClockInclusion clS cl -> Tag clS -> Tag cl
Scheduling
scheduleList :: (Monad m, MonadSchedule m) => NonEmpty (Automaton m a b) -> Automaton m a (NonEmpty b) Source #
Run several automata concurrently.
Whenever one automaton outputs a value, it is returned together with all other values that happen to be output at the same time.
schedulePair :: (Monad m, MonadSchedule m) => Automaton m a b -> Automaton m a b -> Automaton m a b Source #
Run two automata concurrently.
Whenever one automaton returns a value, it is returned.
This is similar to scheduleList
, but more efficient.
runningSchedule :: (Monad m, MonadSchedule m, Clock m cl1, Clock m cl2, Time cl1 ~ Time cl2) => cl1 -> cl2 -> RunningClock m (Time cl1) (Tag cl1) -> RunningClock m (Time cl2) (Tag cl2) -> RunningClock m (Time cl1) (Either (Tag cl1) (Tag cl2)) Source #
Run two running clocks concurrently.
initSchedule :: (Time cl1 ~ Time cl2, Monad m, MonadSchedule m, Clock m cl1, Clock m cl2) => cl1 -> cl2 -> RunningClockInit m (Time cl1) (Either (Tag cl1) (Tag cl2)) Source #
A schedule implements a combination of two clocks.
It outputs a time stamp and an Either
value,
which specifies which of the two subclocks has ticked.
Composite clocks
Sequentially combined clocks
data SequentialClock cl1 cl2 Source #
Two clocks can be combined with a schedule as a clock for an asynchronous sequential composition of signal networks.
Time cl1 ~ Time cl2 => SequentialClock | |
|
Instances
(Monad m, MonadSchedule m, Clock m cl1, Clock m cl2) => Clock m (SequentialClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule type Time (SequentialClock cl1 cl2) Source # type Tag (SequentialClock cl1 cl2) Source # initClock :: SequentialClock cl1 cl2 -> RunningClockInit m (Time (SequentialClock cl1 cl2)) (Tag (SequentialClock cl1 cl2)) Source # | |
(GetClockProxy cl1, GetClockProxy cl2) => GetClockProxy (SequentialClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (SequentialClock cl1 cl2) Source # | |
type Tag (SequentialClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule | |
type Time (SequentialClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule |
type SeqClock cl1 cl2 = SequentialClock cl1 cl2 Source #
Abbrevation synonym.
Parallelly combined clocks
data ParallelClock cl1 cl2 Source #
Two clocks can be combined with a schedule as a clock for an asynchronous parallel composition of signal networks.
Time cl1 ~ Time cl2 => ParallelClock | |
|
Instances
(Monad m, MonadSchedule m, Clock m cl1, Clock m cl2) => Clock m (ParallelClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule type Time (ParallelClock cl1 cl2) Source # type Tag (ParallelClock cl1 cl2) Source # initClock :: ParallelClock cl1 cl2 -> RunningClockInit m (Time (ParallelClock cl1 cl2)) (Tag (ParallelClock cl1 cl2)) Source # | |
(GetClockProxy cl1, GetClockProxy cl2) => GetClockProxy (ParallelClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (ParallelClock cl1 cl2) Source # | |
type Tag (ParallelClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule | |
type Time (ParallelClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule |
type ParClock cl1 cl2 = ParallelClock cl1 cl2 Source #
Abbrevation synonym.
Navigating the clock tree
type family In cl where ... Source #
The clock that represents the rate at which data enters the system.
In (SequentialClock cl1 cl2) = In cl1 | |
In (ParallelClock cl1 cl2) = ParallelClock (In cl1) (In cl2) | |
In cl = cl |
type family Out cl where ... Source #
The clock that represents the rate at which data leaves the system.
Out (SequentialClock cl1 cl2) = Out cl2 | |
Out (ParallelClock cl1 cl2) = ParallelClock (Out cl1) (Out cl2) | |
Out cl = cl |
data LastTime cl where Source #
A tree representing possible last times to which the constituents of a clock may have ticked.
SequentialLastTime :: LastTime cl1 -> LastTime cl2 -> LastTime (SequentialClock cl1 cl2) | |
ParallelLastTime :: LastTime cl1 -> LastTime cl2 -> LastTime (ParallelClock cl1 cl2) | |
LeafLastTime :: Time cl -> LastTime cl |
data ParClockInclusion clS cl where Source #
An inclusion of a clock into a tree of parallel compositions of clocks.
ParClockInL :: ParClockInclusion (ParallelClock clL clR) cl -> ParClockInclusion clL cl | |
ParClockInR :: ParClockInclusion (ParallelClock clL clR) cl -> ParClockInclusion clR cl | |
ParClockRefl :: ParClockInclusion cl cl |
parClockTagInclusion :: ParClockInclusion clS cl -> Tag clS -> Tag cl Source #
Generates a tag for the composite clock from a tag of a leaf clock, given a parallel clock inclusion.