>b      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abCThe phases every signal goes through during a superstep: before or after sampling. cd;A signal generator is the only source of stateful signals. FInternally, computes a signal structure and adds the new variables to an existing update pool. efg>A dynamic set of actions to update a network without breaking consistency. 1A signal can be thought of as a function of type Nat -> a, and its h6 instance agrees with that intuition. Internally, is (represented by a sampling computation. ijEmbedding a signal into an k! environment. Repeated calls to Dthe computation returned cause the whole network to be updated, and <the current sample of the top-level signal is produced as a @result. The computation accepts a global parameter that will be Fdistributed to all signals. For instance, this can be the time step, .if we want to model continuous-time signals. &the generator of the top-level signal %the computation to sample the signal l<Auxiliary function used by all the primitives that create a mutable variable. sampling function aging function 'the mutable variable behind the signal the pool of update actions The 8 transfer function emits the value of a signal from the Fprevious superstep, starting with the filler value given in the first  argument. initial output the signal to delay :Memoising combinator. It can be used to cache results of Gapplicative combinators in case they are used in several places. Other than that, it is equivalent to m. signal to memoise >A reactive signal that takes the value to output from a monad Ccarried by its input. It is possible to create new signals in the monad. *a stream of generators to potentially run <A signal that can be directly fed through the sink function Freturned. This can be used to attach the network to the outer world. GNote that this is optional, as all the input of the network can be fed =in through the global parameter, although that is not really convenient for many signals. initial value )the signal and an IO function to feed it @A pure stateful signal. The initial state is the first output, Gand every following output is calculated from the previous one and the  value of the global parameter. =A stateful transfer function. The current input affects the Fcurrent output, i.e. the initial state given in the first argument is ?considered to appear before the first output, and can never be Gobserved. Every output is derived from the current value of the input 7signal, the global parameter and the previous output. A printing action within the  monad. n5Error message for unimplemented instance functions. oEquality test is impossible. pThe Show* instance is only defined for the sake of q...    r:The phases every signal goes through during a superstep. st CA signal generator is the only source of stateful signals. It can $be thought of as a function of type Nat -> a, where the result is an Garbitrary data structure that can potentially contain new signals, and Dthe argument is the creation time of these new signals. It exposes the u9 interface, which makes it possible to define signals in terms of each other. vwx>A dynamic set of actions to update a network without breaking consistency. 1A signal can be thought of as a function of type Nat -> a, where +the argument is the sampling time, and the h instance agrees ?with the intuition (bind corresponds to extracting the current  sample). y Embedding a signal into an k! environment. Repeated calls to Dthe computation returned cause the whole network to be updated, and Dthe current sample of the top-level signal is produced as a result. ?This is the only way to extract a signal generator outside the >network, and it is equivalent to passing zero to the function representing the generator. &the generator of the top-level signal %the computation to sample the signal z<Auxiliary function used by all the primitives that create a mutable variable. sampling function aging function 'the mutable variable behind the signal the pool of update actions the signal created The  8 transfer function emits the value of a signal from the Fprevious superstep, starting with the filler value given in the first Aargument. It can be thought of as the following function (which 2should also make it clear why the return value is  ):    delay x0 s t_start t_sample  | t_start == t_sample = x0  | t_start < t_sample = s (t_sample-1) ! | otherwise = error "Premature sample!" CThe way signal generators are extracted ensures that the error can never happen.  initial output at creation time the signal to delay the delayed signal ?A reactive signal that takes the value to output from a signal Fgenerator carried by its input with the sampling time provided as the Atime of generation. It is possible to create new signals in the 8monad. It can be thought of as the following function:   4 generator g t_start t_sample = g t_sample t_sample It has to live in the  % monad, because it needs to maintain =an internal state to be able to cache the current sample for ?efficiency reasons. However, this state is not carried between &samples, therefore starting time doesn't matter and can be ignored.  the signal of generators to run #the signal of generated structures :Memoising combinator. It can be used to cache results of Eapplicative combinators in case they are used in several places. It !is observationally equivalent to m in the   monad. the signal to cache 4a signal observationally equivalent to the argument <A signal that can be directly fed through the sink function ?returned. This can be used to attach the network to the outer world. initial value )the signal and an IO function to feed it @A pure stateful signal. The initial state is the first output, @and every subsequent state is derived from the preceding one by Capplying a pure transformation. It is equivalent to the following  expression:   stateful x0 f = { $ sig ->   x0 (f | sig) initial state state transformation =A stateful transfer function. The current input affects the Fcurrent output, i.e. the initial state given in the first argument is ?considered to appear before the first output, and can never be @observed, and subsequent states are determined by combining the Fpreceding state with the current output of the input signal using the Bfunction supplied. It is equivalent to the following expression:   transfer x0 f s = { $ sig -> } f s |   x0 sig initial internal state state updater function  input signal ~5Error message for unimplemented instance functions. Equality test is impossible. The Show* instance is only defined for the sake of q...    CThe phases every signal goes through during a superstep: before or after sampling. ;A signal generator is the only source of stateful signals. FInternally, computes a signal structure and adds the new variables to an existing update pool. >A dynamic set of actions to update a network without breaking consistency. 1A signal can be thought of as a function of type Nat -> a, and its h6 instance agrees with that intuition. Internally, is (represented by a sampling computation. Embedding a signal into an k! environment. Repeated calls to Dthe computation returned cause the whole network to be updated, and <the current sample of the top-level signal is produced as a @result. The computation accepts a global parameter that will be Fdistributed to all signals. For instance, this can be the time step, .if we want to model continuous-time signals. &the generator of the top-level signal %the computation to sample the signal <Auxiliary function used by all the primitives that create a mutable variable. sampling function aging function 'the mutable variable behind the signal the pool of update actions The 8 transfer function emits the value of a signal from the Fprevious superstep, starting with the filler value given in the first  argument. initial output the signal to delay :Memoising combinator. It can be used to cache results of Gapplicative combinators in case they are used in several places. Other than that, it is equivalent to m. signal to memoise >A reactive signal that takes the value to output from a monad Ccarried by its input. It is possible to create new signals in the monad. *a stream of generators to potentially run <A signal that can be directly fed through the sink function Freturned. This can be used to attach the network to the outer world. GNote that this is optional, as all the input of the network can be fed =in through the global parameter, although that is not really convenient for many signals. initial value )the signal and an IO function to feed it @A pure stateful signal. The initial state is the first output, Gand every following output is calculated from the previous one and the  value of the global parameter. =A stateful transfer function. The current input affects the Fcurrent output, i.e. the initial state given in the first argument is ?considered to appear before the first output, and can never be Gobserved. Every output is derived from the current value of the input @signal, the global parameter and the previous output. The only Fexception is when a transfer function sits in a loop without a delay. @In this case, a delay will be inserted at a single place during Gruntime (i.e. the previous output of the node affected will be reused) %to resolve the circular dependency. A printing action within the  monad. 5Error message for unimplemented instance functions. Equality test is impossible. The Show* instance is only defined for the sake of q...    The 9 transfer function takes a bool signal and emits another Fbool signal that turns true only at the moment when there is a rising edge on the input. The + transfer function behaves as a latch on a  ,input: it keeps its state when the input is , and replaces it with the input otherwise. Initial output Maybe signal to latch on %Point-wise equality of two signals. 'Point-wise inequality of two signals. !'Point-wise comparison of two signals. "'Point-wise comparison of two signals. #'Point-wise comparison of two signals. $'Point-wise comparison of two signals. %'Point-wise OR of two boolean signals. &(Point-wise AND of two boolean signals.  !"#$%&  !"#$&%  !"#$%&2'5The possible structures of a node are defined by the ' type. Note that the SNFx# nodes are only needed to optimise 4applicatives, they can all be expressed in terms of SNK and SNA. (SNF5 f: liftA5 f )SNF4 f: liftA4 f *SNF3 f: liftA3 f +SNF2 f: liftA2 f ,SNF1 f: fmap f -SNKA s l: equivalent to s while aging signal l .SND s: the s! signal delayed by one superstep /SNE r*: opaque reference to connect peripherals 0SNM b sm3: signal generator that executes the monad carried  by sm whenever b% is true, and outputs the result (or  undefined when b is false) 1SNH ss r: the higher-order signal ss collapsed into a  signal cached in reference r; r is used during the aging  phase 2 SNA sf sx!: pointwise function application 3 SNT s x t1: stateful transfer function, which also depends  on an input signal s 4SNS x t: stateful generator, where x is current state and  t is the update function 5SNK x : constantly x 6?A node can have four states that distinguish various stages of sampling and aging. 7Aged x s is the aged version of signal s paired with its  current value x 8 Sampled x s is signal s paired with its current value x 9 Sampling s is signal s after its current value was " requested, but not yet delivered :Ready s is simply the signal s that was not sampled yet ;0A signal is conceptually a time-varying value. <=3A restricted monad to create stateful signals in. >?@BSinks are used when feeding input into peripheral-bound signals. A%Time is continuous. Nothing fancy. B,A printing function that can be used in the =. "Provided for debugging purposes. CBYou can uncomment the verbose version of this function to see the &applicative optimisations in action. D5Error message for unimplemented instance functions. E Creating a reference within the =. Used for stateful  signals. F:Creating a reference as a pure value. Used for stateless  signals. GCSampling the signal and all of its dependencies, at the same time. We don':t need the aged signal in the current superstep, only the Bcurrent value, so we sample before propagating the changes, which Bmight require the fresh sample because of recursive definitions. H;Aging the network of signals the given signal depends on. I-Finalising aged signals for the next round. J?Aging the signal. Stateful signals have their state forced to Bprevent building up big thunks. The other nodes are structurally  static. KASampling the signal at the current moment. This is where static Enodes propagate changes to those they depend on. Transfer functions (3>) work without delay, i.e. the effects of their input signals (can be observed in the same superstep. L@Sampling the signal with some kind of delay in order to resolve Cdependency loops. Transfer functions simply return their previous Eoutput (delays can be considered a special case, because they always  do that, so L) is never called with them), while other +types of signals are always handled by the K function, so it is Bnot possible to create a working stateful loop composed of solely stateless combinators. M@Advancing the whole network that the given signal depends on by 2the amount of time given in the second argument. the top-level signal the amount of time to advance  the current value of the signal NAA pure stateful signal. The initial state is the first output. initial state state transformation O=A stateful transfer function. The current input affects the Fcurrent output, i.e. the initial state given in the first argument is Gconsidered to appear before the first output, and can only be directly observed by the L function. initial internal state state updater function  input signal P<A continuous sampler that flattens a higher-order signal by #outputting its current snapshots. signal to flatten Q>A reactive signal that takes the value to output from a monad Fcarried by its input when a boolean control signal is true, otherwise  it outputs /. It is possible to create new signals in the )monad and also to print debug messages. control (trigger) signal &a stream of monads to potentially run R)A helper function to wrap any value in a  depending on a boolean condition. S<A signal that can be directly fed through the sink function ?returned. This can be used to attach the network to the outer world. initial value )the signal and an IO function to feed it TThe T8 transfer function emits the value of a signal from the Fprevious superstep, starting with the filler value given in the first Gargument. It has to be a primitive, otherwise it could not be used to prevent automatic delays. initial output the signal to delay U@Dependency injection to allow aging signals whose output is not >necessarily needed to produce the current sample of the first  argument. It's equivalent to (flip . liftA2 . flip) const, as it &evaluates its second argument first. the actual output 4a signal guaranteed to age when this one is sampled GThe equality test checks whether two signals are physically the same. The Show* instance is only defined for the sake of q... The + instance with run-time optimisation. The  Goperator tries to move all the pure parts to its left side in order to Hflatten the structure, hence cutting down on book-keeping costs. Since Dapplicatives are used with pure functions and lifted values most of 6the time, one can gain a lot by merging these nodes. /'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTU/A@=>?B;<6:987'543210/.-,+*)(CDEFGHIJKLMNOPQRSTU/'543210/.-,+*)(()*+,-./0123456:987789:;<<=>?>?@ABCDEFGHIJKLMNOPQRSTUVETraversing the network starting from the given signal and converting 2it into a string containing the graph in Graphviz ( http://www.graphviz.org/+) dot format. Stateful nodes are coloured according to their type. FThe results might differ depending on whether this function is called Fbefore or after sampling (this also affects the actual network!), but )the networks should be still equivalent. VVV WA short alternative name for U. XThe X9 transfer function takes a bool signal and emits another Fbool signal that turns true only at the moment when there is a rising edge on the input. YThe Y+ transfer function behaves as a latch on a  ,input: it keeps its state when the input is , and replaces it with the input otherwise. Initial output Maybe signal to latch on Z%Point-wise equality of two signals. ['Point-wise inequality of two signals. \'Point-wise comparison of two signals. ]'Point-wise comparison of two signals. ^'Point-wise comparison of two signals. _'Point-wise comparison of two signals. `'Point-wise OR of two boolean signals. a(Point-wise AND of two boolean signals. ;=?@ABMNOPQRSTUWXYZ[\]^_`aA@;=??MSNOTPQYRXUWZ[\]^_a`B WXYZ[\]^_`a                !"#$%&'()*+,-./ 0123456789:;<=>?@AB C DEFGH,/IJKLMN0OPQRSLMT8UVLWXHY/LZ[IJK0SLZ\L]^L_`8UVH,./IJK0OS8UVLabLacUVdL_eL_fghijklmnopqrstuvwxyz{| elerea-1.2.0FRP.Elerea.Experimental.ParamFRP.Elerea.Experimental.SimpleFRP.Elerea.Experimental.DelayedFRP.Elerea.ExperimentalFRP.Elerea.InternalFRP.Elerea.Graph FRP.Elerea SignalGenSignalstartdelaymemo generatorexternalstatefultransferdebugedge-->==@/=@<@<=@>=@>@||@&&@ SignalNodeSNF5SNF4SNF3SNF2SNF1SNKASNDSNESNMSNHSNASNTSNSSNK SignalTransAgedSampledSamplingReadyS SignalMonadSM createSignalSinkDTime signalDebugdebugLogunimp makeSignalmakeSignalUnsafe signalValueagecommitadvancesample sampleDelayed superstepsamplertoMaybe keepAlive signalToDot.@. storeJustPhaseSGunSG UpdatePoolbaseGHC.BaseMonadunSghc-prim GHC.TypesIO addSignalreturn $fEqSignal $fShowSignalGHC.NumNumUpdatedControl.Monad.FixMonadFixmfix Data.Functor<$>Control.ApplicativeliftA2 Data.MaybeMaybeNothing$fApplicativeSignal Applicative<*> SignalInfoNoneLift5Lift4Lift3Lift2Lift1DelayExternal GeneratorSamplerAppTransferStatefulConst SignalStoreIdgetPtr buildStore insertSignal nodeLabel