Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type BehaviorF m time a b = BehaviourF m time a b
- type BehaviourF m time a b = forall cl. time ~ Time cl => ClSF m cl a b
- type Behavior m time a = Behaviour m time a
- type Behaviour m time a = forall cl. time ~ Time cl => ClSignal m cl a
- type ClSignal m cl a = forall arbitrary. ClSF m cl arbitrary a
- type ClSF m cl a b = MSF (ReaderT (TimeInfo cl) m) a b
- hoistClSF :: (Monad m1, Monad m2) => (forall c. m1 c -> m2 c) -> ClSF m1 cl a b -> ClSF m2 cl a b
- hoistClSFAndClock :: (Monad m1, Monad m2) => (forall c. m1 c -> m2 c) -> ClSF m1 cl a b -> ClSF m2 (HoistClock m1 m2 cl) a b
- liftClSF :: (Monad m, MonadTrans t, Monad (t m)) => ClSF m cl a b -> ClSF (t m) cl a b
- liftClSFAndClock :: (Monad m, MonadTrans t, Monad (t m)) => ClSF m cl a b -> ClSF (t m) (LiftClock m t cl) a b
- timeless :: Monad m => MSF m a b -> ClSF m cl a b
- arrMCl :: Monad m => (a -> m b) -> ClSF m cl a b
- constMCl :: Monad m => m b -> ClSF m cl a b
- mapMaybe :: Monad m => ClSF m cl a b -> ClSF m cl (Maybe a) (Maybe b)
- module Control.Arrow
- leftApp :: ArrowApply a => a b c -> a (Either b d) (Either c d)
- (^<<) :: Arrow a => (c -> d) -> a b c -> a b d
- (<<^) :: Arrow a => a c d -> (b -> c) -> a b d
- (>>^) :: Arrow a => a b c -> (c -> d) -> a b d
- (^>>) :: Arrow a => (b -> c) -> a c d -> a b d
- returnA :: Arrow a => a b b
- class Category a => Arrow (a :: Type -> Type -> Type) where
- newtype Kleisli (m :: Type -> Type) a b = Kleisli {
- runKleisli :: a -> m b
- class Arrow a => ArrowZero (a :: Type -> Type -> Type) where
- zeroArrow :: a b c
- class ArrowZero a => ArrowPlus (a :: Type -> Type -> Type) where
- (<+>) :: a b c -> a b c -> a b c
- class Arrow a => ArrowChoice (a :: Type -> Type -> Type) where
- class Arrow a => ArrowApply (a :: Type -> Type -> Type) where
- app :: a (a b c, b) c
- newtype ArrowMonad (a :: Type -> Type -> Type) b = ArrowMonad (a () b)
- class Arrow a => ArrowLoop (a :: Type -> Type -> Type) where
- loop :: a (b, d) (c, d) -> a b c
- (>>>) :: forall k cat (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c
- (<<<) :: forall k cat (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c
- pauseOn :: Show a => (a -> Bool) -> String -> MSF IO a a
- traceWhen :: (Monad m, Show a) => (a -> Bool) -> (String -> m ()) -> String -> MSF m a a
- traceWith :: (Monad m, Show a) => (String -> m ()) -> String -> MSF m a a
- trace :: Show a => String -> MSF IO a a
- repeatedly :: forall (m :: Type -> Type) a. Monad m => (a -> a) -> a -> MSF m () a
- unfold :: forall (m :: Type -> Type) a b. Monad m => (a -> (b, a)) -> a -> MSF m () b
- mealy :: forall (m :: Type -> Type) a s b. Monad m => (a -> s -> (b, s)) -> s -> MSF m a b
- accumulateWith :: forall (m :: Type -> Type) a s. Monad m => (a -> s -> s) -> s -> MSF m a s
- mappendFrom :: forall n (m :: Type -> Type). (Monoid n, Monad m) => n -> MSF m n n
- mappendS :: forall n (m :: Type -> Type). (Monoid n, Monad m) => MSF m n n
- sumFrom :: forall v s (m :: Type -> Type). (VectorSpace v s, Monad m) => v -> MSF m v v
- sumS :: forall v s (m :: Type -> Type). (VectorSpace v s, Monad m) => MSF m v v
- count :: forall n (m :: Type -> Type) a. (Num n, Monad m) => MSF m a n
- fifo :: forall (m :: Type -> Type) a. Monad m => MSF m [a] (Maybe a)
- next :: forall (m :: Type -> Type) b a. Monad m => b -> MSF m a b -> MSF m a b
- iPost :: forall (m :: Type -> Type) b a. Monad m => b -> MSF m a b -> MSF m a b
- iPre :: forall (m :: Type -> Type) a. Monad m => a -> MSF m a a
- withSideEffect_ :: Monad m => m b -> MSF m a a
- withSideEffect :: Monad m => (a -> m b) -> MSF m a a
- mapMaybeS :: forall (m :: Type -> Type) a b. Monad m => MSF m a b -> MSF m (Maybe a) (Maybe b)
- type MStream (m :: Type -> Type) a = MSF m () a
- type MSink (m :: Type -> Type) a = MSF m a ()
- morphS :: (Monad m2, Monad m1) => (forall c. m1 c -> m2 c) -> MSF m1 a b -> MSF m2 a b
- liftTransS :: forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a b. (MonadTrans t, Monad m, Monad (t m)) => MSF m a b -> MSF (t m) a b
- liftBaseS :: forall (m2 :: Type -> Type) (m1 :: Type -> Type) a b. (Monad m2, MonadBase m1 m2) => MSF m1 a b -> MSF m2 a b
- liftBaseM :: forall (m2 :: Type -> Type) m1 a b. (Monad m2, MonadBase m1 m2) => (a -> m1 b) -> MSF m2 a b
- arrM :: Monad m => (a -> m b) -> MSF m a b
- constM :: Monad m => m b -> MSF m a b
- reactimate :: Monad m => MSF m () () -> m ()
- embed :: Monad m => MSF m a b -> [a] -> m [b]
- feedback :: forall (m :: Type -> Type) c a b. Monad m => c -> MSF m (a, c) (b, c) -> MSF m a b
- morphGS :: Monad m2 => (forall c. (a1 -> m1 (b1, c)) -> a2 -> m2 (b2, c)) -> MSF m1 a1 b1 -> MSF m2 a2 b2
- data MSF (m :: Type -> Type) a b
- data UTCTime
- type family Diff time
- class TimeDifference (Diff time) => TimeDomain time where
- class TimeDifference d where
- difference :: d -> d -> d
- newtype NumTimeDomain a = NumTimeDomain {
- fromNumTimeDomain :: a
- type IOClock m cl = HoistClock IO m cl
- type LiftClock m t cl = HoistClock m (t m) cl
- data HoistClock m1 m2 cl = HoistClock {
- unhoistedClock :: cl
- monadMorphism :: forall a. m1 a -> m2 a
- data RescaledClockS m cl time tag = RescaledClockS {
- unscaledClockS :: cl
- rescaleS :: RescalingSInit m cl time tag
- data RescaledClockM m cl time = RescaledClockM {
- unscaledClockM :: cl
- rescaleM :: RescalingM m cl time
- data RescaledClock cl time = RescaledClock {
- unscaledClock :: cl
- rescale :: Rescaling cl time
- type RescalingSInit m cl time tag = Time cl -> m (RescalingS m cl time tag, time)
- type RescalingS m cl time tag = MSF m (Time cl, Tag cl) (time, tag)
- type RescalingM m cl time = Time cl -> m time
- type Rescaling cl time = Time cl -> time
- data TimeInfo cl = TimeInfo {}
- class TimeDomain (Time cl) => Clock m cl where
- type RunningClockInit m time tag = m (RunningClock m time tag, time)
- type RunningClock m time tag = MSF m () (time, tag)
- retag :: Time cl1 ~ Time cl2 => (Tag cl1 -> Tag cl2) -> TimeInfo cl1 -> TimeInfo cl2
- rescaleMToSInit :: Monad m => (time1 -> m time2) -> time1 -> m (MSF m (time1, tag) (time2, tag), time2)
- rescaledClockToM :: Monad m => RescaledClock cl time -> RescaledClockM m cl time
- rescaledClockMToS :: Monad m => RescaledClockM m cl time -> RescaledClockS m cl time (Tag cl)
- rescaledClockToS :: Monad m => RescaledClock cl time -> RescaledClockS m cl time (Tag cl)
- liftClock :: (Monad m, MonadTrans t) => cl -> LiftClock m t cl
- ioClock :: MonadIO m => cl -> IOClock m cl
Documentation
type BehaviorF m time a b = BehaviourF m time a b Source #
Compatibility to U.S. american spelling.
type BehaviourF m time a b = forall cl. time ~ Time cl => ClSF m cl a b Source #
A (side-effectful) behaviour function is a time-aware synchronous stream
function that doesn't depend on a particular clock.
time
denotes the TimeDomain
.
type Behaviour m time a = forall cl. time ~ Time cl => ClSignal m cl a Source #
A (side-effectful) behaviour is a time-aware stream
that doesn't depend on a particular clock.
time
denotes the TimeDomain
.
type ClSignal m cl a = forall arbitrary. ClSF m cl arbitrary a Source #
A clocked signal is a ClSF
with no input required.
It produces its output on its own.
type ClSF m cl a b = MSF (ReaderT (TimeInfo cl) m) a b Source #
A (synchronous, clocked) monadic stream function
with the additional side effect of being time-aware,
that is, reading the current TimeInfo
of the clock cl
.
hoistClSF :: (Monad m1, Monad m2) => (forall c. m1 c -> m2 c) -> ClSF m1 cl a b -> ClSF m2 cl a b Source #
Hoist a ClSF
along a monad morphism.
hoistClSFAndClock :: (Monad m1, Monad m2) => (forall c. m1 c -> m2 c) -> ClSF m1 cl a b -> ClSF m2 (HoistClock m1 m2 cl) a b Source #
Hoist a ClSF
and its clock along a monad morphism.
liftClSF :: (Monad m, MonadTrans t, Monad (t m)) => ClSF m cl a b -> ClSF (t m) cl a b Source #
Lift a ClSF
into a monad transformer.
liftClSFAndClock :: (Monad m, MonadTrans t, Monad (t m)) => ClSF m cl a b -> ClSF (t m) (LiftClock m t cl) a b Source #
Lift a ClSF
and its clock into a monad transformer.
timeless :: Monad m => MSF m a b -> ClSF m cl a b Source #
A monadic stream function without dependency on time
is a ClSF
for any clock.
arrMCl :: Monad m => (a -> m b) -> ClSF m cl a b Source #
Utility to lift Kleisli arrows directly to ClSF
s.
mapMaybe :: Monad m => ClSF m cl a b -> ClSF m cl (Maybe a) (Maybe b) Source #
Call a ClSF
every time the input is 'Just a'.
Caution: This will not change the time differences since the last tick.
For example,
while integrate 1
is approximately the same as timeInfoOf sinceInit
,
mapMaybe $ integrate 1
is very different from
mapMaybe $ timeInfoOf sinceInit
.
The former only integrates when the input is Just 1
,
whereas the latter always returns the correct time since initialisation.
module Control.Arrow
leftApp :: ArrowApply a => a b c -> a (Either b d) (Either c d) #
Any instance of ArrowApply
can be made into an instance of
ArrowChoice
by defining left
= leftApp
.
(^<<) :: Arrow a => (c -> d) -> a b c -> a b d infixr 1 #
Postcomposition with a pure function (right-to-left variant).
(<<^) :: Arrow a => a c d -> (b -> c) -> a b d infixr 1 #
Precomposition with a pure function (right-to-left variant).
class Category a => Arrow (a :: Type -> Type -> Type) where #
The basic arrow class.
Instances should satisfy the following laws:
arr
id =id
arr
(f >>> g) =arr
f >>>arr
gfirst
(arr
f) =arr
(first
f)first
(f >>> g) =first
f >>>first
gfirst
f >>>arr
fst
=arr
fst
>>> ffirst
f >>>arr
(id
*** g) =arr
(id
*** g) >>>first
ffirst
(first
f) >>>arr
assoc =arr
assoc >>>first
f
where
assoc ((a,b),c) = (a,(b,c))
The other combinators have sensible default definitions, which may be overridden for efficiency.
Lift a function to an arrow.
first :: a b c -> a (b, d) (c, d) #
Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.
second :: a b c -> a (d, b) (d, c) #
A mirror image of first
.
The default definition may be overridden with a more efficient version if desired.
(***) :: a b c -> a b' c' -> a (b, b') (c, c') infixr 3 #
Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
(&&&) :: a b c -> a b c' -> a b (c, c') infixr 3 #
Fanout: send the input to both argument arrows and combine their output.
The default definition may be overridden with a more efficient version if desired.
newtype Kleisli (m :: Type -> Type) a b #
Kleisli arrows of a monad.
Kleisli | |
|
Instances
Monad m => Arrow (Kleisli m) | Since: base-2.1 |
MonadPlus m => ArrowZero (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
MonadPlus m => ArrowPlus (Kleisli m) | Since: base-2.1 |
Monad m => ArrowChoice (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
Monad m => ArrowApply (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
MonadFix m => ArrowLoop (Kleisli m) | Beware that for many monads (those for which the Since: base-2.1 |
Defined in Control.Arrow | |
Monad m => Category (Kleisli m :: Type -> Type -> Type) | Since: base-3.0 |
Generic1 (Kleisli m a :: Type -> Type) | Since: base-4.14.0.0 |
Monad m => Monad (Kleisli m a) | Since: base-4.14.0.0 |
Functor m => Functor (Kleisli m a) | Since: base-4.14.0.0 |
Applicative m => Applicative (Kleisli m a) | Since: base-4.14.0.0 |
Defined in Control.Arrow | |
MonadPlus m => MonadPlus (Kleisli m a) | Since: base-4.14.0.0 |
Alternative m => Alternative (Kleisli m a) | Since: base-4.14.0.0 |
Generic (Kleisli m a b) | Since: base-4.14.0.0 |
type Rep1 (Kleisli m a :: Type -> Type) | |
type Rep (Kleisli m a b) | |
Defined in Control.Arrow |
class Arrow a => ArrowZero (a :: Type -> Type -> Type) where #
Instances
MonadPlus m => ArrowZero (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
(ArrowZero p, ArrowZero q) => ArrowZero (Product p q) | |
Defined in Data.Bifunctor.Product | |
(Applicative f, ArrowZero p) => ArrowZero (Tannen f p) | |
Defined in Data.Bifunctor.Tannen |
class ArrowZero a => ArrowPlus (a :: Type -> Type -> Type) where #
A monoid on arrows.
class Arrow a => ArrowChoice (a :: Type -> Type -> Type) where #
Choice, for arrows that support it. This class underlies the
if
and case
constructs in arrow notation.
Instances should satisfy the following laws:
left
(arr
f) =arr
(left
f)left
(f >>> g) =left
f >>>left
gf >>>
arr
Left
=arr
Left
>>>left
fleft
f >>>arr
(id
+++ g) =arr
(id
+++ g) >>>left
fleft
(left
f) >>>arr
assocsum =arr
assocsum >>>left
f
where
assocsum (Left (Left x)) = Left x assocsum (Left (Right y)) = Right (Left y) assocsum (Right z) = Right (Right z)
The other combinators have sensible default definitions, which may be overridden for efficiency.
left :: a b c -> a (Either b d) (Either c d) #
Feed marked inputs through the argument arrow, passing the rest through unchanged to the output.
right :: a b c -> a (Either d b) (Either d c) #
A mirror image of left
.
The default definition may be overridden with a more efficient version if desired.
(+++) :: a b c -> a b' c' -> a (Either b b') (Either c c') infixr 2 #
Split the input between the two argument arrows, retagging and merging their outputs. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
(|||) :: a b d -> a c d -> a (Either b c) d infixr 2 #
Fanin: Split the input between the two argument arrows and merge their outputs.
The default definition may be overridden with a more efficient version if desired.
Instances
Monad m => ArrowChoice (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
ArrowChoice ((->) :: Type -> Type -> Type) | Since: base-2.1 |
(ArrowChoice p, ArrowChoice q) => ArrowChoice (Product p q) | |
Defined in Data.Bifunctor.Product | |
(Applicative f, ArrowChoice p) => ArrowChoice (Tannen f p) | |
Defined in Data.Bifunctor.Tannen |
class Arrow a => ArrowApply (a :: Type -> Type -> Type) where #
Some arrows allow application of arrow inputs to other inputs. Instances should satisfy the following laws:
first
(arr
(\x ->arr
(\y -> (x,y)))) >>>app
=id
first
(arr
(g >>>)) >>>app
=second
g >>>app
first
(arr
(>>> h)) >>>app
=app
>>> h
Such arrows are equivalent to monads (see ArrowMonad
).
Instances
Monad m => ArrowApply (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
ArrowApply ((->) :: Type -> Type -> Type) | Since: base-2.1 |
Defined in Control.Arrow |
newtype ArrowMonad (a :: Type -> Type -> Type) b #
The ArrowApply
class is equivalent to Monad
: any monad gives rise
to a Kleisli
arrow, and any instance of ArrowApply
defines a monad.
ArrowMonad (a () b) |
Instances
class Arrow a => ArrowLoop (a :: Type -> Type -> Type) where #
The loop
operator expresses computations in which an output value
is fed back as input, although the computation occurs only once.
It underlies the rec
value recursion construct in arrow notation.
loop
should satisfy the following laws:
- extension
loop
(arr
f) =arr
(\ b ->fst
(fix
(\ (c,d) -> f (b,d))))- left tightening
loop
(first
h >>> f) = h >>>loop
f- right tightening
loop
(f >>>first
h) =loop
f >>> h- sliding
loop
(f >>>arr
(id
*** k)) =loop
(arr
(id
*** k) >>> f)- vanishing
loop
(loop
f) =loop
(arr
unassoc >>> f >>>arr
assoc)- superposing
second
(loop
f) =loop
(arr
assoc >>>second
f >>>arr
unassoc)
where
assoc ((a,b),c) = (a,(b,c)) unassoc (a,(b,c)) = ((a,b),c)
Instances
MonadFix m => ArrowLoop (Kleisli m) | Beware that for many monads (those for which the Since: base-2.1 |
Defined in Control.Arrow | |
ArrowLoop ((->) :: Type -> Type -> Type) | Since: base-2.1 |
Defined in Control.Arrow | |
(ArrowLoop p, ArrowLoop q) => ArrowLoop (Product p q) | |
Defined in Data.Bifunctor.Product | |
(Applicative f, ArrowLoop p) => ArrowLoop (Tannen f p) | |
Defined in Data.Bifunctor.Tannen |
(>>>) :: forall k cat (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c infixr 1 #
Left-to-right composition
(<<<) :: forall k cat (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c infixr 1 #
Right-to-left composition
pauseOn :: Show a => (a -> Bool) -> String -> MSF IO a a #
Outputs every input sample, with a given message prefix, when a condition is met, and waits for some input / enter to continue.
traceWhen :: (Monad m, Show a) => (a -> Bool) -> (String -> m ()) -> String -> MSF m a a #
Outputs every input sample, with a given message prefix, using an auxiliary printing function, when a condition is met.
traceWith :: (Monad m, Show a) => (String -> m ()) -> String -> MSF m a a #
Outputs every input sample, with a given message prefix, using an auxiliary printing function.
repeatedly :: forall (m :: Type -> Type) a. Monad m => (a -> a) -> a -> MSF m () a #
Generate outputs using a step-wise generation function and an initial
value. Version of unfold
in which the output and the new accumulator are
the same. Should be equal to f a -> unfold (f >>> dup) a
.
unfold :: forall (m :: Type -> Type) a b. Monad m => (a -> (b, a)) -> a -> MSF m () b #
Generate outputs using a step-wise generation function and an initial value.
mealy :: forall (m :: Type -> Type) a s b. Monad m => (a -> s -> (b, s)) -> s -> MSF m a b #
Applies a transfer function to the input and an accumulator, returning the updated accumulator and output.
accumulateWith :: forall (m :: Type -> Type) a s. Monad m => (a -> s -> s) -> s -> MSF m a s #
Applies a function to the input and an accumulator, outputting the updated
accumulator. Equal to f s0 -> feedback s0 $ arr (uncurry f >>> dup)
.
mappendFrom :: forall n (m :: Type -> Type). (Monoid n, Monad m) => n -> MSF m n n #
Accumulate the inputs, starting from an initial monoid value.
mappendS :: forall n (m :: Type -> Type). (Monoid n, Monad m) => MSF m n n #
Accumulate the inputs, starting from mempty
.
sumFrom :: forall v s (m :: Type -> Type). (VectorSpace v s, Monad m) => v -> MSF m v v #
Sums the inputs, starting from an initial vector.
sumS :: forall v s (m :: Type -> Type). (VectorSpace v s, Monad m) => MSF m v v #
Sums the inputs, starting from zero.
count :: forall n (m :: Type -> Type) a. (Num n, Monad m) => MSF m a n #
Count the number of simulation steps. Produces 1, 2, 3,...
fifo :: forall (m :: Type -> Type) a. Monad m => MSF m [a] (Maybe a) #
Buffers and returns the elements in FIFO order, returning Nothing
whenever the buffer is empty.
next :: forall (m :: Type -> Type) b a. Monad m => b -> MSF m a b -> MSF m a b #
Preprends a fixed output to an MSF
, shifting the output.
iPost :: forall (m :: Type -> Type) b a. Monad m => b -> MSF m a b -> MSF m a b #
Preprends a fixed output to an MSF
. The first input is completely
ignored.
Delay a signal by one sample.
withSideEffect_ :: Monad m => m b -> MSF m a a #
Produces an additional side effect and passes the input unchanged.
withSideEffect :: Monad m => (a -> m b) -> MSF m a a #
Applies a function to produce an additional side effect and passes the input unchanged.
type MStream (m :: Type -> Type) a = MSF m () a #
A stream is an MSF
that produces outputs, while ignoring the input. It
can obtain the values from a monadic context.
type MSink (m :: Type -> Type) a = MSF m a () #
A sink is an MSF
that consumes inputs, while producing no output. It
can consume the values with side effects.
morphS :: (Monad m2, Monad m1) => (forall c. m1 c -> m2 c) -> MSF m1 a b -> MSF m2 a b #
Apply trans-monadic actions (in an arbitrary way).
This is just a convenience function when you have a function to move across
monads, because the signature of morphGS
is a bit complex.
liftTransS :: forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a b. (MonadTrans t, Monad m, Monad (t m)) => MSF m a b -> MSF (t m) a b #
Lift inner monadic actions in monad stacks.
liftBaseS :: forall (m2 :: Type -> Type) (m1 :: Type -> Type) a b. (Monad m2, MonadBase m1 m2) => MSF m1 a b -> MSF m2 a b #
Lift innermost monadic actions in monad stack (generalisation of
liftIO
).
liftBaseM :: forall (m2 :: Type -> Type) m1 a b. (Monad m2, MonadBase m1 m2) => (a -> m1 b) -> MSF m2 a b #
Monadic lifting from one monad into another
reactimate :: Monad m => MSF m () () -> m () #
Run an MSF
indefinitely passing a unit-carrying input stream.
embed :: Monad m => MSF m a b -> [a] -> m [b] #
Apply a monadic stream function to a list.
Because the result is in a monad, it may be necessary to traverse the whole
list to evaluate the value in the results to WHNF. For example, if the
monad is the maybe monad, this may not produce anything if the MSF
produces Nothing
at any point, so the output stream cannot consumed
progressively.
To explore the output progressively, use arrM
and (>>>)
', together with
some action that consumes/actuates on the output.
This is called runSF
in Liu, Cheng, Hudak, "Causal Commutative Arrows and
Their Optimization"
feedback :: forall (m :: Type -> Type) c a b. Monad m => c -> MSF m (a, c) (b, c) -> MSF m a b #
Well-formed looped connection of an output component as a future input.
:: Monad m2 | |
=> (forall c. (a1 -> m1 (b1, c)) -> a2 -> m2 (b2, c)) | The natural transformation. |
-> MSF m1 a1 b1 | |
-> MSF m2 a2 b2 |
Generic lifting of a morphism to the level of MSF
s.
Natural transformation to the level of MSF
s.
Mathematical background: The type a -> m (b, c)
is a functor in c
,
and MSF m a b
is its greatest fixpoint, i.e. it is isomorphic to the type
a -> m (b, MSF m a b)
, by definition. The types m
, a
and b
are
parameters of the functor. Taking a fixpoint is functorial itself, meaning
that a morphism (a natural transformation) of two such functors gives a
morphism (an ordinary function) of their fixpoints.
This is in a sense the most general "abstract" lifting function, i.e. the
most general one that only changes input, output and side effect types, and
doesn't influence control flow. Other handling functions like exception
handling or ListT
broadcasting necessarily change control flow.
data MSF (m :: Type -> Type) a b #
Stepwise, side-effectful MSF
s without implicit knowledge of time.
MSF
s should be applied to streams or executed indefinitely or until they
terminate. See reactimate
and reactimateB
for details. In general,
calling the value constructor MSF
or the function unMSF
is discouraged.
This is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.
Instances
Eq UTCTime | |
Data UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UTCTime -> c UTCTime # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UTCTime # toConstr :: UTCTime -> Constr # dataTypeOf :: UTCTime -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UTCTime) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UTCTime) # gmapT :: (forall b. Data b => b -> b) -> UTCTime -> UTCTime # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r # gmapQ :: (forall d. Data d => d -> u) -> UTCTime -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UTCTime -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # | |
Ord UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
NFData UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
TimeDomain UTCTime | Differences between |
type Diff UTCTime | |
Defined in Data.TimeDomain |
The type of differences or durations between two timestamps
Instances
type Diff Double | |
Defined in Data.TimeDomain | |
type Diff Float | |
Defined in Data.TimeDomain | |
type Diff Integer | |
Defined in Data.TimeDomain | |
type Diff () | |
Defined in Data.TimeDomain type Diff () = () | |
type Diff UTCTime | |
Defined in Data.TimeDomain | |
type Diff (NumTimeDomain a) | |
Defined in Data.TimeDomain |
class TimeDifference (Diff time) => TimeDomain time where #
A time domain is an affine space representing a notion of time, such as real time, simulated time, steps, or a completely different notion.
Expected law:
(t1diffTime
t3)difference
(t1diffTime
t2) = t2diffTime
t3
Instances
TimeDomain Double | |
TimeDomain Float | |
TimeDomain Integer | |
TimeDomain () | |
TimeDomain UTCTime | Differences between |
Num a => TimeDomain (NumTimeDomain a) | |
Defined in Data.TimeDomain type Diff (NumTimeDomain a) # diffTime :: NumTimeDomain a -> NumTimeDomain a -> Diff (NumTimeDomain a) # |
class TimeDifference d where #
A type of durations, or differences betweens time stamps.
For the expected law, see TimeDomain
.
difference :: d -> d -> d #
Calculate the difference between two durations,
compatibly with diffTime
.
Instances
TimeDifference Double | |
Defined in Data.TimeDomain difference :: Double -> Double -> Double # | |
TimeDifference Float | |
Defined in Data.TimeDomain difference :: Float -> Float -> Float # | |
TimeDifference Integer | |
Defined in Data.TimeDomain difference :: Integer -> Integer -> Integer # | |
TimeDifference () | |
Defined in Data.TimeDomain difference :: () -> () -> () # | |
Num a => TimeDifference (NumTimeDomain a) | |
Defined in Data.TimeDomain difference :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # |
newtype NumTimeDomain a #
Any Num
can be wrapped to form a TimeDomain
.
Instances
Num a => Num (NumTimeDomain a) | |
Defined in Data.TimeDomain (+) :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # (-) :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # (*) :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # negate :: NumTimeDomain a -> NumTimeDomain a # abs :: NumTimeDomain a -> NumTimeDomain a # signum :: NumTimeDomain a -> NumTimeDomain a # fromInteger :: Integer -> NumTimeDomain a # | |
Num a => TimeDomain (NumTimeDomain a) | |
Defined in Data.TimeDomain type Diff (NumTimeDomain a) # diffTime :: NumTimeDomain a -> NumTimeDomain a -> Diff (NumTimeDomain a) # | |
Num a => TimeDifference (NumTimeDomain a) | |
Defined in Data.TimeDomain difference :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # | |
type Diff (NumTimeDomain a) | |
Defined in Data.TimeDomain |
type LiftClock m t cl = HoistClock m (t m) cl Source #
Lift a clock type into a monad transformer.
data HoistClock m1 m2 cl Source #
Applying a monad morphism yields a new clock.
HoistClock | |
|
Instances
(Monad m1, Monad m2, Clock m1 cl) => Clock m2 (HoistClock m1 m2 cl) Source # | |
Defined in FRP.Rhine.Clock type Time (HoistClock m1 m2 cl) Source # type Tag (HoistClock m1 m2 cl) Source # initClock :: HoistClock m1 m2 cl -> RunningClockInit m2 (Time (HoistClock m1 m2 cl)) (Tag (HoistClock m1 m2 cl)) Source # | |
GetClockProxy cl => GetClockProxy (HoistClock m1 m2 cl) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (HoistClock m1 m2 cl) Source # | |
type Time (HoistClock m1 m2 cl) Source # | |
Defined in FRP.Rhine.Clock | |
type Tag (HoistClock m1 m2 cl) Source # | |
Defined in FRP.Rhine.Clock |
data RescaledClockS m cl time tag Source #
Instead of a mere function as morphism of time domains, we can transform one time domain into the other with a monadic stream function.
RescaledClockS | |
|
Instances
(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClockS m cl time tag) Source # | |
Defined in FRP.Rhine.Clock type Time (RescaledClockS m cl time tag) Source # type Tag (RescaledClockS m cl time tag) Source # initClock :: RescaledClockS m cl time tag -> RunningClockInit m (Time (RescaledClockS m cl time tag)) (Tag (RescaledClockS m cl time tag)) Source # | |
GetClockProxy cl => GetClockProxy (RescaledClockS m cl time tag) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (RescaledClockS m cl time tag) Source # | |
type Time (RescaledClockS m cl time tag) Source # | |
Defined in FRP.Rhine.Clock | |
type Tag (RescaledClockS m cl time tag) Source # | |
Defined in FRP.Rhine.Clock |
data RescaledClockM m cl time Source #
Instead of a mere function as morphism of time domains, we can transform one time domain into the other with an effectful morphism.
RescaledClockM | |
|
Instances
(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClockM m cl time) Source # | |
Defined in FRP.Rhine.Clock type Time (RescaledClockM m cl time) Source # type Tag (RescaledClockM m cl time) Source # initClock :: RescaledClockM m cl time -> RunningClockInit m (Time (RescaledClockM m cl time)) (Tag (RescaledClockM m cl time)) Source # | |
GetClockProxy cl => GetClockProxy (RescaledClockM m cl time) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (RescaledClockM m cl time) Source # | |
type Time (RescaledClockM m cl time) Source # | |
Defined in FRP.Rhine.Clock | |
type Tag (RescaledClockM m cl time) Source # | |
Defined in FRP.Rhine.Clock |
data RescaledClock cl time Source #
Applying a morphism of time domains yields a new clock.
RescaledClock | |
|
Instances
(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClock cl time) Source # | |
Defined in FRP.Rhine.Clock type Time (RescaledClock cl time) Source # type Tag (RescaledClock cl time) Source # initClock :: RescaledClock cl time -> RunningClockInit m (Time (RescaledClock cl time)) (Tag (RescaledClock cl time)) Source # | |
GetClockProxy cl => GetClockProxy (RescaledClock cl time) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (RescaledClock cl time) Source # | |
type Time (RescaledClock cl time) Source # | |
Defined in FRP.Rhine.Clock | |
type Tag (RescaledClock cl time) Source # | |
Defined in FRP.Rhine.Clock |
type RescalingSInit m cl time tag = Time cl -> m (RescalingS m cl time tag, time) Source #
Like RescalingS
, but allows for an initialisation
of the rescaling morphism, together with the initial time.
type RescalingS m cl time tag = MSF m (Time cl, Tag cl) (time, tag) Source #
An effectful, stateful morphism of time domains is an MSF
that uses side effects to rescale a point in one time domain
into another one.
type RescalingM m cl time = Time cl -> m time Source #
An effectful morphism of time domains is a Kleisli arrow. It can use a side effect to rescale a point in one time domain into another one.
type Rescaling cl time = Time cl -> time Source #
A pure morphism of time domains is just a function.
An annotated, rich time stamp.
class TimeDomain (Time cl) => Clock m cl where Source #
Since we want to leverage Haskell's type system to annotate signal networks by their clocks,
each clock must be an own type, cl
.
Different values of the same clock type should tick at the same speed,
and only differ in implementation details.
Often, clocks are singletons.
The time domain, i.e. type of the time stamps the clock creates.
Additional information that the clock may output at each tick, e.g. if a realtime promise was met, if an event occurred, if one of its subclocks (if any) ticked.
:: cl | The clock value, containing e.g. settings or device parameters |
-> RunningClockInit m (Time cl) (Tag cl) | The stream of time stamps, and the initial time |
The method that produces to a clock value a running clock, i.e. an effectful stream of tagged time stamps together with an initialisation time.
Instances
type RunningClockInit m time tag = m (RunningClock m time tag, time) Source #
When initialising a clock, the initial time is measured (typically by means of a side effect), and a running clock is returned.
type RunningClock m time tag = MSF m () (time, tag) Source #
A clock creates a stream of time stamps and additional information,
possibly together with side effects in a monad m
that cause the environment to wait until the specified time is reached.
retag :: Time cl1 ~ Time cl2 => (Tag cl1 -> Tag cl2) -> TimeInfo cl1 -> TimeInfo cl2 Source #
A utility that changes the tag of a TimeInfo
.
rescaleMToSInit :: Monad m => (time1 -> m time2) -> time1 -> m (MSF m (time1, tag) (time2, tag), time2) Source #
Convert an effectful morphism of time domains into a stateful one with initialisation.
Think of its type as RescalingM m cl time -> RescalingSInit m cl time tag
,
although this type is ambiguous.
rescaledClockToM :: Monad m => RescaledClock cl time -> RescaledClockM m cl time Source #
A RescaledClock
is trivially a RescaledClockM
.
rescaledClockMToS :: Monad m => RescaledClockM m cl time -> RescaledClockS m cl time (Tag cl) Source #
A RescaledClockM
is trivially a RescaledClockS
.
rescaledClockToS :: Monad m => RescaledClock cl time -> RescaledClockS m cl time (Tag cl) Source #
A RescaledClock
is trivially a RescaledClockS
.