rhine-0.5.0.0: Functional Reactive Programming with type-level clocks

Safe HaskellNone
LanguageHaskell2010

FRP.Rhine.Clock

Description

Clocks are the central new notion in Rhine. There are clock types (instances of the Clock type class) and their values.

This module provides the Clock type class, several utilities, and certain general constructions of Clocks, such as clocks lifted along monad morphisms or time rescalings.

Synopsis

Documentation

type IOClock m cl = HoistClock IO m cl Source #

Lift a clock type into MonadIO.

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.

Constructors

HoistClock 

Fields

Instances
(Monad m1, Monad m2, Clock m1 cl) => Clock m2 (HoistClock m1 m2 cl) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type Time (HoistClock m1 m2 cl) :: * Source #

type Tag (HoistClock m1 m2 cl) :: * Source #

Methods

initClock :: HoistClock m1 m2 cl -> RunningClockInit m2 (Time (HoistClock m1 m2 cl)) (Tag (HoistClock m1 m2 cl)) Source #

type Time (HoistClock m1 m2 cl) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Time (HoistClock m1 m2 cl) = Time cl
type Tag (HoistClock m1 m2 cl) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Tag (HoistClock m1 m2 cl) = Tag cl

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.

Constructors

RescaledClockS 

Fields

  • unscaledClockS :: cl

    The clock before the rescaling

  • rescaleS :: RescalingSInit m cl time tag

    The rescaling stream function, and rescaled initial time, depending on the initial time before rescaling

Instances
(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClockS m cl time tag) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type Time (RescaledClockS m cl time tag) :: * Source #

type Tag (RescaledClockS m cl time tag) :: * Source #

Methods

initClock :: RescaledClockS m cl time tag -> RunningClockInit m (Time (RescaledClockS m cl time tag)) (Tag (RescaledClockS m cl time tag)) Source #

type Time (RescaledClockS m cl time tag) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Time (RescaledClockS m cl time tag) = time
type Tag (RescaledClockS m cl time tag) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Tag (RescaledClockS m cl time tag) = tag

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.

Constructors

RescaledClockM 

Fields

Instances
(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClockM m cl time) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type Time (RescaledClockM m cl time) :: * Source #

type Tag (RescaledClockM m cl time) :: * Source #

Methods

initClock :: RescaledClockM m cl time -> RunningClockInit m (Time (RescaledClockM m cl time)) (Tag (RescaledClockM m cl time)) Source #

type Time (RescaledClockM m cl time) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Time (RescaledClockM m cl time) = time
type Tag (RescaledClockM m cl time) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Tag (RescaledClockM m cl time) = Tag cl

data RescaledClock cl time Source #

Applying a morphism of time domains yields a new clock.

Constructors

RescaledClock 

Fields

Instances
(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClock cl time) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type Time (RescaledClock cl time) :: * Source #

type Tag (RescaledClock cl time) :: * Source #

Methods

initClock :: RescaledClock cl time -> RunningClockInit m (Time (RescaledClock cl time)) (Tag (RescaledClock cl time)) Source #

type Time (RescaledClock cl time) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Time (RescaledClock cl time) = time
type Tag (RescaledClock cl time) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Tag (RescaledClock cl time) = Tag cl

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.

data TimeInfo cl Source #

An annotated, rich time stamp.

Constructors

TimeInfo 

Fields

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.

Minimal complete definition

initClock

Associated Types

type Time cl Source #

The time domain, i.e. type of the time stamps the clock creates.

type Tag cl Source #

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.

Methods

initClock Source #

Arguments

:: 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
Clock IO Busy Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Busy

Associated Types

type Time Busy :: * Source #

type Tag Busy :: * Source #

MonadIO m => Clock m StdinClock Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Stdin

Associated Types

type Time StdinClock :: * Source #

type Tag StdinClock :: * Source #

Clock IO (Millisecond n) Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Millisecond

Associated Types

type Time (Millisecond n) :: * Source #

type Tag (Millisecond n) :: * Source #

(Monad m, PureAudioClockRate rate) => Clock m (PureAudioClock rate) Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Audio

Associated Types

type Time (PureAudioClock rate) :: * Source #

type Tag (PureAudioClock rate) :: * Source #

Monad m => Clock m (FixedStep n) Source # 
Instance details

Defined in FRP.Rhine.Clock.FixedStep

Associated Types

type Time (FixedStep n) :: * Source #

type Tag (FixedStep n) :: * Source #

(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClock cl time) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type Time (RescaledClock cl time) :: * Source #

type Tag (RescaledClock cl time) :: * Source #

Methods

initClock :: RescaledClock cl time -> RunningClockInit m (Time (RescaledClock cl time)) (Tag (RescaledClock cl time)) Source #

(Monad m, Clock m cl) => Clock m (SelectClock cl a) Source # 
Instance details

Defined in FRP.Rhine.Clock.Select

Associated Types

type Time (SelectClock cl a) :: * Source #

type Tag (SelectClock cl a) :: * Source #

(MonadIO m, KnownNat bufferSize, AudioClockRate rate) => Clock m (AudioClock rate bufferSize) Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Audio

Associated Types

type Time (AudioClock rate bufferSize) :: * Source #

type Tag (AudioClock rate bufferSize) :: * Source #

Methods

initClock :: AudioClock rate bufferSize -> RunningClockInit m (Time (AudioClock rate bufferSize)) (Tag (AudioClock rate bufferSize)) Source #

(Monad m1, Monad m2, Clock m1 cl) => Clock m2 (HoistClock m1 m2 cl) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type Time (HoistClock m1 m2 cl) :: * Source #

type Tag (HoistClock m1 m2 cl) :: * Source #

Methods

initClock :: HoistClock m1 m2 cl -> RunningClockInit m2 (Time (HoistClock m1 m2 cl)) (Tag (HoistClock m1 m2 cl)) Source #

(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClockM m cl time) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type Time (RescaledClockM m cl time) :: * Source #

type Tag (RescaledClockM m cl time) :: * Source #

Methods

initClock :: RescaledClockM m cl time -> RunningClockInit m (Time (RescaledClockM m cl time)) (Tag (RescaledClockM m cl time)) Source #

(Monad m, Clock m cl1, Clock m cl2) => Clock m (ParallelClock m cl1 cl2) Source # 
Instance details

Defined in FRP.Rhine.Schedule

Associated Types

type Time (ParallelClock m cl1 cl2) :: * Source #

type Tag (ParallelClock m cl1 cl2) :: * Source #

Methods

initClock :: ParallelClock m cl1 cl2 -> RunningClockInit m (Time (ParallelClock m cl1 cl2)) (Tag (ParallelClock m cl1 cl2)) Source #

(Monad m, Clock m cl1, Clock m cl2) => Clock m (SequentialClock m cl1 cl2) Source # 
Instance details

Defined in FRP.Rhine.Schedule

Associated Types

type Time (SequentialClock m cl1 cl2) :: * Source #

type Tag (SequentialClock m cl1 cl2) :: * Source #

Methods

initClock :: SequentialClock m cl1 cl2 -> RunningClockInit m (Time (SequentialClock m cl1 cl2)) (Tag (SequentialClock m cl1 cl2)) Source #

(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClockS m cl time tag) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type Time (RescaledClockS m cl time tag) :: * Source #

type Tag (RescaledClockS m cl time tag) :: * Source #

Methods

initClock :: RescaledClockS m cl time tag -> RunningClockInit m (Time (RescaledClockS m cl time tag)) (Tag (RescaledClockS m cl time tag)) Source #

(Monad m, NonemptyNatList v) => Clock (ScheduleT Integer m) (Periodic v) Source # 
Instance details

Defined in FRP.Rhine.Clock.Periodic

Associated Types

type Time (Periodic v) :: * Source #

type Tag (Periodic v) :: * Source #

MonadIO m => Clock (EventChanT event m) (EventClock event) Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Event

Associated Types

type Time (EventClock event) :: * Source #

type Tag (EventClock event) :: * Source #

Methods

initClock :: EventClock event -> RunningClockInit (EventChanT event m) (Time (EventClock event)) (Tag (EventClock event)) Source #

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.

genTimeInfo :: (Monad m, Clock m cl) => cl -> Time cl -> MSF m (Time cl, Tag cl) (TimeInfo cl) Source #

Given a clock value and an initial time, generate a stream of time stamps.

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.

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.

liftClock :: (Monad m, MonadTrans t) => cl -> LiftClock m t cl Source #

Lift a clock value into a monad transformer.

ioClock :: MonadIO m => cl -> IOClock m cl Source #

Lift a clock value into MonadIO.

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).

(>>^) :: Arrow a => a b c -> (c -> d) -> a b d infixr 1 #

Postcomposition with a pure function.

(^>>) :: Arrow a => (b -> c) -> a c d -> a b d infixr 1 #

Precomposition with a pure function.

returnA :: Arrow a => a b b #

The identity arrow, which plays the role of return in arrow notation.

class Category a => Arrow (a :: * -> * -> *) where #

The basic arrow class.

Instances should satisfy the following laws:

where

assoc ((a,b),c) = (a,(b,c))

The other combinators have sensible default definitions, which may be overridden for efficiency.

Minimal complete definition

arr, (first | (***))

Methods

arr :: (b -> c) -> a b c #

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.

Instances
Monad m => Arrow (Kleisli m)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

arr :: (b -> c) -> Kleisli m b c #

first :: Kleisli m b c -> Kleisli m (b, d) (c, d) #

second :: Kleisli m b c -> Kleisli m (d, b) (d, c) #

(***) :: Kleisli m b c -> Kleisli m b' c' -> Kleisli m (b, b') (c, c') #

(&&&) :: Kleisli m b c -> Kleisli m b c' -> Kleisli m b (c, c') #

Monad m => Arrow (MSF m)

Arrow instance for MSFs.

Instance details

Defined in Data.MonadicStreamFunction.Core

Methods

arr :: (b -> c) -> MSF m b c #

first :: MSF m b c -> MSF m (b, d) (c, d) #

second :: MSF m b c -> MSF m (d, b) (d, c) #

(***) :: MSF m b c -> MSF m b' c' -> MSF m (b, b') (c, c') #

(&&&) :: MSF m b c -> MSF m b c' -> MSF m b (c, c') #

Arrow ((->) :: * -> * -> *)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

arr :: (b -> c) -> b -> c #

first :: (b -> c) -> (b, d) -> (c, d) #

second :: (b -> c) -> (d, b) -> (d, c) #

(***) :: (b -> c) -> (b' -> c') -> (b, b') -> (c, c') #

(&&&) :: (b -> c) -> (b -> c') -> b -> (c, c') #

(Applicative f, Arrow p) => Arrow (Tannen f p) 
Instance details

Defined in Data.Bifunctor.Tannen

Methods

arr :: (b -> c) -> Tannen f p b c #

first :: Tannen f p b c -> Tannen f p (b, d) (c, d) #

second :: Tannen f p b c -> Tannen f p (d, b) (d, c) #

(***) :: Tannen f p b c -> Tannen f p b' c' -> Tannen f p (b, b') (c, c') #

(&&&) :: Tannen f p b c -> Tannen f p b c' -> Tannen f p b (c, c') #

newtype Kleisli (m :: * -> *) a b #

Kleisli arrows of a monad.

Constructors

Kleisli 

Fields

Instances
Monad m => Arrow (Kleisli m)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

arr :: (b -> c) -> Kleisli m b c #

first :: Kleisli m b c -> Kleisli m (b, d) (c, d) #

second :: Kleisli m b c -> Kleisli m (d, b) (d, c) #

(***) :: Kleisli m b c -> Kleisli m b' c' -> Kleisli m (b, b') (c, c') #

(&&&) :: Kleisli m b c -> Kleisli m b c' -> Kleisli m b (c, c') #

MonadPlus m => ArrowZero (Kleisli m)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

zeroArrow :: Kleisli m b c #

MonadPlus m => ArrowPlus (Kleisli m)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

(<+>) :: Kleisli m b c -> Kleisli m b c -> Kleisli m b c #

Monad m => ArrowChoice (Kleisli m)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

left :: Kleisli m b c -> Kleisli m (Either b d) (Either c d) #

right :: Kleisli m b c -> Kleisli m (Either d b) (Either d c) #

(+++) :: Kleisli m b c -> Kleisli m b' c' -> Kleisli m (Either b b') (Either c c') #

(|||) :: Kleisli m b d -> Kleisli m c d -> Kleisli m (Either b c) d #

Monad m => ArrowApply (Kleisli m)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

app :: Kleisli m (Kleisli m b c, b) c #

MonadFix m => ArrowLoop (Kleisli m)

Beware that for many monads (those for which the >>= operation is strict) this instance will not satisfy the right-tightening law required by the ArrowLoop class.

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

loop :: Kleisli m (b, d) (c, d) -> Kleisli m b c #

Monad m => Category (Kleisli m :: * -> * -> *)

Since: base-3.0

Instance details

Defined in Control.Arrow

Methods

id :: Kleisli m a a #

(.) :: Kleisli m b c -> Kleisli m a b -> Kleisli m a c #

class Arrow a => ArrowZero (a :: * -> * -> *) where #

Minimal complete definition

zeroArrow

Methods

zeroArrow :: a b c #

Instances
MonadPlus m => ArrowZero (Kleisli m)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

zeroArrow :: Kleisli m b c #

(Applicative f, ArrowZero p) => ArrowZero (Tannen f p) 
Instance details

Defined in Data.Bifunctor.Tannen

Methods

zeroArrow :: Tannen f p b c #

class ArrowZero a => ArrowPlus (a :: * -> * -> *) where #

A monoid on arrows.

Minimal complete definition

(<+>)

Methods

(<+>) :: a b c -> a b c -> a b c infixr 5 #

An associative operation with identity zeroArrow.

Instances
MonadPlus m => ArrowPlus (Kleisli m)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

(<+>) :: Kleisli m b c -> Kleisli m b c -> Kleisli m b c #

(Applicative f, ArrowPlus p) => ArrowPlus (Tannen f p) 
Instance details

Defined in Data.Bifunctor.Tannen

Methods

(<+>) :: Tannen f p b c -> Tannen f p b c -> Tannen f p b c #

class Arrow a => ArrowChoice (a :: * -> * -> *) where #

Choice, for arrows that support it. This class underlies the if and case constructs in arrow notation.

Instances should satisfy the following laws:

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.

Methods

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

Instance details

Defined in Control.Arrow

Methods

left :: Kleisli m b c -> Kleisli m (Either b d) (Either c d) #

right :: Kleisli m b c -> Kleisli m (Either d b) (Either d c) #

(+++) :: Kleisli m b c -> Kleisli m b' c' -> Kleisli m (Either b b') (Either c c') #

(|||) :: Kleisli m b d -> Kleisli m c d -> Kleisli m (Either b c) d #

ArrowChoice ((->) :: * -> * -> *)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

left :: (b -> c) -> Either b d -> Either c d #

right :: (b -> c) -> Either d b -> Either d c #

(+++) :: (b -> c) -> (b' -> c') -> Either b b' -> Either c c' #

(|||) :: (b -> d) -> (c -> d) -> Either b c -> d #

(Applicative f, ArrowChoice p) => ArrowChoice (Tannen f p) 
Instance details

Defined in Data.Bifunctor.Tannen

Methods

left :: Tannen f p b c -> Tannen f p (Either b d) (Either c d) #

right :: Tannen f p b c -> Tannen f p (Either d b) (Either d c) #

(+++) :: Tannen f p b c -> Tannen f p b' c' -> Tannen f p (Either b b') (Either c c') #

(|||) :: Tannen f p b d -> Tannen f p c d -> Tannen f p (Either b c) d #

class Arrow a => ArrowApply (a :: * -> * -> *) where #

Some arrows allow application of arrow inputs to other inputs. Instances should satisfy the following laws:

Such arrows are equivalent to monads (see ArrowMonad).

Minimal complete definition

app

Methods

app :: a (a b c, b) c #

Instances
Monad m => ArrowApply (Kleisli m)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

app :: Kleisli m (Kleisli m b c, b) c #

ArrowApply ((->) :: * -> * -> *)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

app :: (b -> c, b) -> c #

newtype ArrowMonad (a :: * -> * -> *) b #

The ArrowApply class is equivalent to Monad: any monad gives rise to a Kleisli arrow, and any instance of ArrowApply defines a monad.

Constructors

ArrowMonad (a () b) 
Instances
ArrowApply a => Monad (ArrowMonad a)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

(>>=) :: ArrowMonad a a0 -> (a0 -> ArrowMonad a b) -> ArrowMonad a b #

(>>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b #

return :: a0 -> ArrowMonad a a0 #

fail :: String -> ArrowMonad a a0 #

Arrow a => Functor (ArrowMonad a)

Since: base-4.6.0.0

Instance details

Defined in Control.Arrow

Methods

fmap :: (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b #

(<$) :: a0 -> ArrowMonad a b -> ArrowMonad a a0 #

Arrow a => Applicative (ArrowMonad a)

Since: base-4.6.0.0

Instance details

Defined in Control.Arrow

Methods

pure :: a0 -> ArrowMonad a a0 #

(<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b #

liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c #

(*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b #

(<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 #

(ArrowApply a, ArrowPlus a) => MonadPlus (ArrowMonad a)

Since: base-4.6.0.0

Instance details

Defined in Control.Arrow

Methods

mzero :: ArrowMonad a a0 #

mplus :: ArrowMonad a a0 -> ArrowMonad a a0 -> ArrowMonad a a0 #

ArrowPlus a => Alternative (ArrowMonad a)

Since: base-4.6.0.0

Instance details

Defined in Control.Arrow

Methods

empty :: ArrowMonad a a0 #

(<|>) :: ArrowMonad a a0 -> ArrowMonad a a0 -> ArrowMonad a a0 #

some :: ArrowMonad a a0 -> ArrowMonad a [a0] #

many :: ArrowMonad a a0 -> ArrowMonad a [a0] #

class Arrow a => ArrowLoop (a :: * -> * -> *) 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)

Minimal complete definition

loop

Methods

loop :: a (b, d) (c, d) -> a b c #

Instances
MonadFix m => ArrowLoop (Kleisli m)

Beware that for many monads (those for which the >>= operation is strict) this instance will not satisfy the right-tightening law required by the ArrowLoop class.

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

loop :: Kleisli m (b, d) (c, d) -> Kleisli m b c #

ArrowLoop ((->) :: * -> * -> *)

Since: base-2.1

Instance details

Defined in Control.Arrow

Methods

loop :: ((b, d) -> (c, d)) -> b -> c #

(Applicative f, ArrowLoop p) => ArrowLoop (Tannen f p) 
Instance details

Defined in Data.Bifunctor.Tannen

Methods

loop :: Tannen f p (b, d) (c, d) -> Tannen f p b c #

(>>>) :: Category cat => cat a b -> cat b c -> cat a c infixr 1 #

Left-to-right composition

(<<<) :: 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.

trace :: Show a => String -> MSF IO a a #

Outputs every input sample, with a given message prefix.

repeatedly :: 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 :: Monad m => (a -> (b, a)) -> a -> MSF m () b #

Generate outputs using a step-wise generation function and an initial value.

accumulateWith :: Monad m => (a -> s -> s) -> s -> MSF m a s #

Applies a function to the input and an accumulator, outputing the accumulator. Equal to f s0 -> feedback s0 $ arr (uncurry f >>> dup).

mappendFrom :: (Monoid n, Monad m) => n -> MSF m n n #

Accumulate the inputs, starting from an initial monoid value.

mappendS :: (Monoid n, Monad m) => MSF m n n #

Accumulate the inputs, starting from mempty.

sumFrom :: (RModule v, Monad m) => v -> MSF m v v #

Sums the inputs, starting from an initial vector.

sumS :: (RModule v, Monad m) => MSF m v v #

Sums the inputs, starting from zero.

count :: (Num n, Monad m) => MSF m a n #

Count the number of simulation steps. Produces 1, 2, 3,...

fifo :: Monad m => MSF m [a] (Maybe a) #

Buffers and returns the elements in FIFO order, returning Nothing whenever the buffer is empty.

next :: Monad m => b -> MSF m a b -> MSF m a b #

Preprends a fixed output to an MSF, shifting the output.

iPost :: Monad m => b -> MSF m a b -> MSF m a b #

Preprends a fixed output to an MSF. The first input is completely ignored.

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.

mapMaybeS :: Monad m => MSF m a b -> MSF m (Maybe a) (Maybe b) #

Apply an MSF to every input. Freezes temporarily if the input is Nothing, and continues as soon as a Just is received.

mapMSF :: Monad m => MSF m a b -> MSF m [a] [b] #

Apply an MSF to every input.

arrM_ :: Monad m => m b -> MSF m a b #

Lifts a computation into a Stream.

insert :: Monad m => MSF m (m a) a #

Pre-inserts an input sample.

type MStream (m :: * -> *) a = MSF m () a #

A stream is an MSF that produces outputs ignoring the input. It can obtain the values from a monadic context.

type MSink (m :: * -> *) a = MSF m a () #

A stream is an MSF that produces outputs producing no output. It can consume the values with side effects.

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 liftMSF 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 :: 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.

switch :: Monad m => MSF m a (b, Maybe c) -> (c -> MSF m a b) -> MSF m a b #

Switching applies one MSF until it produces a Just output, and then "turns on" a continuation and runs it.

A more advanced and comfortable approach to switching is given by Exceptions in Except

delay :: Monad m => a -> MSF m a a #

See iPre.

iPre #

Arguments

:: Monad m 
=> a

First output

-> MSF m a a 

Delay a signal by one sample.

liftMSFPurer :: (Monad m2, Monad m1) => (forall c. m1 c -> m2 c) -> MSF m1 a b -> MSF m2 a b #

Lifting purer monadic actions (in an arbitrary way)

liftMSFBase :: (Monad m2, MonadBase m1 m2) => MSF m1 a b -> MSF m2 a b #

Lift innermost monadic actions in a monad stacks (generalisation of liftIO).

liftMSFTrans :: (MonadTrans t, Monad m, Monad (t m)) => MSF m a b -> MSF (t m) a b #

Lift inner monadic actions in monad stacks.

liftS :: (Monad m2, MonadBase m1 m2) => (a -> m1 b) -> MSF m2 a b #

Monadic lifting from one monad into another

arrM :: Monad m => (a -> m b) -> MSF m a b #

Apply a monadic transformation to every element of the input stream.

Generalisation of arr from Arrow to monadic functions.

data MSF (m :: * -> *) a b #

Stepwise, side-effectful MSFs without implicit knowledge of time.

MSFs 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.

Constructors

MSF 

Fields

Instances
Monad m => Arrow (MSF m)

Arrow instance for MSFs.

Instance details

Defined in Data.MonadicStreamFunction.Core

Methods

arr :: (b -> c) -> MSF m b c #

first :: MSF m b c -> MSF m (b, d) (c, d) #

second :: MSF m b c -> MSF m (d, b) (d, c) #

(***) :: MSF m b c -> MSF m b' c' -> MSF m (b, b') (c, c') #

(&&&) :: MSF m b c -> MSF m b c' -> MSF m b (c, c') #

Monad m => Category (MSF m :: * -> * -> *)

Instance definition for Category. Defines id and ..

Instance details

Defined in Data.MonadicStreamFunction.Core

Methods

id :: MSF m a a #

(.) :: MSF m b c -> MSF m a b -> MSF m a c #

Functor m => Functor (MSF m a)

Functor instance for MSFs.

Instance details

Defined in Data.MonadicStreamFunction.Core

Methods

fmap :: (a0 -> b) -> MSF m a a0 -> MSF m a b #

(<$) :: a0 -> MSF m a b -> MSF m a a0 #

(Functor m, Monad m) => Applicative (MSF m a)

Applicative instance for MSFs.

Instance details

Defined in Data.MonadicStreamFunction.Core

Methods

pure :: a0 -> MSF m a a0 #

(<*>) :: MSF m a (a0 -> b) -> MSF m a a0 -> MSF m a b #

liftA2 :: (a0 -> b -> c) -> MSF m a a0 -> MSF m a b -> MSF m a c #

(*>) :: MSF m a a0 -> MSF m a b -> MSF m a b #

(<*) :: MSF m a a0 -> MSF m a b -> MSF m a a0 #

type Groundring (MSF m a v) 
Instance details

Defined in Data.MonadicStreamFunction.Instances.VectorSpace

type Groundring (MSF m a v) = Groundring v

data UTCTime #

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 
Instance details

Defined in Data.Time.Clock.Internal.UTCTime

Methods

(==) :: UTCTime -> UTCTime -> Bool #

(/=) :: UTCTime -> UTCTime -> Bool #

Data UTCTime 
Instance details

Defined in Data.Time.Clock.Internal.UTCTime

Methods

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 :: (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 
Instance details

Defined in Data.Time.Clock.Internal.UTCTime

NFData UTCTime 
Instance details

Defined in Data.Time.Clock.Internal.UTCTime

Methods

rnf :: UTCTime -> () #

ParseTime UTCTime 
Instance details

Defined in Data.Time.Format.Parse

TimeDomain UTCTime Source # 
Instance details

Defined in FRP.Rhine.TimeDomain

Associated Types

type Diff UTCTime :: * Source #

type Diff UTCTime Source # 
Instance details

Defined in FRP.Rhine.TimeDomain

newtype NumTimeDomain a Source #

Any Num can be wrapped to form a TimeDomain.

Constructors

NumTimeDomain 

Fields

class TimeDomain time where Source #

A time domain is an affine space representing a notion of time, such as real time, simulated time, steps, or a completely different notion.

Minimal complete definition

diffTime

Associated Types

type Diff time Source #

Methods

diffTime :: time -> time -> Diff time Source #

Instances
TimeDomain Double Source # 
Instance details

Defined in FRP.Rhine.TimeDomain

Associated Types

type Diff Double :: * Source #

TimeDomain Float Source # 
Instance details

Defined in FRP.Rhine.TimeDomain

Associated Types

type Diff Float :: * Source #

TimeDomain Integer Source # 
Instance details

Defined in FRP.Rhine.TimeDomain

Associated Types

type Diff Integer :: * Source #

TimeDomain () Source # 
Instance details

Defined in FRP.Rhine.TimeDomain

Associated Types

type Diff () :: * Source #

Methods

diffTime :: () -> () -> Diff () Source #

TimeDomain UTCTime Source # 
Instance details

Defined in FRP.Rhine.TimeDomain

Associated Types

type Diff UTCTime :: * Source #

Num a => TimeDomain (NumTimeDomain a) Source # 
Instance details

Defined in FRP.Rhine.TimeDomain

Associated Types

type Diff (NumTimeDomain a) :: * Source #