u*nR      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQ'R9The phases every signal goes through during a superstep. ST?A signal generator is the only source of stateful signals. It ) can be thought of as a function of type Nat -> a , where the D result is an arbitrary data structure that can potentially contain A new signals, and the argument is the creation time of these new  signals. It exposes the U interface, which makes it @ possible to define signals in terms of each other. Unlike the B simple variant, the denotation of signal generators differs from : that of signals. We will use the following notation for  generators:   g = <|g0 g1 g2 ...|> DJust like signals, generators behave as functions of time, but they % can also refer to the clock signal:  / g t_start s_clock = [g0,g1,g2,...] !! t_start BThe conceptual difference between the two notions is that signals B are passed a sampling time, while generators expect a start time = that will be the creation time of all the freshly generated % signals in the resulting structure. VWX>A dynamic set of actions to update a network without breaking  consistency. YA pointer to an update pair. Zclocked subnetwork superstep [ordinary signal \=A pair of actions to update a signal in two phases: internal A update without changing the output, finalisation (throwing away  previous state). ;A signal represents a value changing over time. It can be " thought of as a function of type Nat -> a, where the argument is  the sampling time, and the ] instance agrees with the @ intuition (bind corresponds to extracting the current sample). D Signals and the values they carry are denoted the following way in  the documentation:   s = <<s0 s1 s2 ...>> This says that s is a signal that reads s0 during the first  sampling, s15 during the second and so on. You can also think of  s as the following function:  ) s t_sample = [s0,s1,s2,...] !! t_sample @Signals are constrained to be sampled sequentially, there is no A random access. The only way to observe their output is through  . ^_Embedding a signal into an `! environment. Repeated calls to E the computation returned cause the whole network to be updated, and = the current sample of the top-level signal is produced as a D result. This is the only way to extract a signal generator outside C the network, and it is equivalent to passing zero to the function < representing the generator. The clock associated with the > top-level signal ticks at every sampling point. In general:  P replicateM n =<< start <|<<x0 x1 x2 x3 ...>> ...|> == take n [x0,x1,x2,x3,...]  Example:   do $ smp <- start (stateful 3 (+2))  res <- replicateM 5 smp  print res Output:  [3,5,7,9,11] &the generator of the top-level signal %the computation to sample the signal a$Performing the two-phase superstep. b<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 1 combinator is the elementary building block for E adding state to the signal network by constructing delayed versions > of a signal that emit a given value at creation time and the + previous output of the signal afterwards. 5The clock signal associated to the generator affects  D elements the following way: if the clock signal is true, the delay ? works as usual, otherwise it remembers its current output and > throws away its current input. If we consider signals to be D functions of time (natural numbers), the behaviour of delay can be & described by the following function:  % delay x0 s t_start s_clock t_sample  | t_start == t_sample = x0 / | t_start < t_sample = if s_clock t_sample 1 then s (t_sample-1) J else delay x0 s t_start s_clock (t_sample-1) < | otherwise = error "stream doesn't exist yet" +The way signal generators are extracted by  ensures that  the error can never happen. Example (requires the DoRec extension):   do  smp <- start $ do - rec let fib'' = liftA2 (+) fib' fib # fib' <- delay 1 fib'' ! fib <- delay 1 fib'  return fib  res <- replicateM 7 smp  print res Output:  [1,1,2,3,5,8,13]  initial output at creation time the signal to delay the delayed signal =A formal conversion from signals to signal generators, which E effectively allows for retrieving the current value of a previously @ created signal within a generator. This includes both signals B defined in an external scope as well as those created earlier in D the same generator. It can be modelled by the following function: ( snapshot s t_start s_clock = s t_start cAuxiliary function. ?A reactive signal that takes the value to output from a signal C generator carried by its input with the sampling time provided as @ the start time for the generated structure. It is possible to ? create new signals in the monad, which is the key to defining  dynamic data-flow networks.  " generator << <|x00 x01 x02 ...|> " <|x10 x11 x12 ...|> " <|x20 x21 x22 ...|>  ... ' >> = <| <<x00 x11 x22 ...>> ' <<x00 x11 x22 ...>> ' <<x00 x11 x22 ...>>  ...  |> 0It can be thought of as the following function:  D generator g t_start s_clock t_sample = g t_sample s_clock t_sample It has to live in the  monad, because it needs to C maintain an internal state to be able to cache the current sample D for efficiency reasons. However, this state is not carried between $ samples, therefore start time doesn't matter and can be ignored. E Also, even though it does not make use of the clock itself, part of @ its job is to distribute it among the newly generated signals. -Refer to the longer example at the bottom of FRP.Elerea.Simple to  see how it can be used.  the signal of generators to run #the signal of generated structures :Memoising combinator. It can be used to cache results of B applicative combinators in case they are used in several places. D Unlike in the simple variant, it is not observationally equivalent  to d in the $ monad, because it only samples its 4 input signal when the associated clock ticks. The memo 7 combinator can be modelled by the following function:  ! memo s t_start s_clock t_sample # | s_clock t_sample = s t_sample < | otherwise = memo s t_start s_clock (t_sample-1) For instance, if s = f <$> s', then f will be recalculated  once for each sampling of s". This can be avoided by writing s  < - memo (f <$> s') instead. However,  incurs a small 4 overhead, therefore it should not be used blindly. BAll the functions defined in this module return memoised signals. the signal to cache 4a signal observationally equivalent to the argument =A signal that is true exactly once: the first time the input C signal is true. Afterwards, it is constantly false, and it holds . no reference to the input signal. Note that  always follows D the master clock, i.e. the fastest one, therefore it never creates  a long spike of True*. For instance (assuming the rest of the  input is constantly False):  2 until <<False False True True False True ...>> = L <| <<False False True False False False False False False False ...>> L << --- False True False False False False False False False ...>> L << --- --- True False False False False False False False ...>> L << --- --- --- True False False False False False False ...>> L << --- --- --- --- False True False False False False ...>> L << --- --- --- --- --- True False False False False ...>> L << --- --- --- --- --- --- False False False False ...>>  ...  |> DIt is observationally equivalent to the following expression (which  would hold onto s forever):   until s = global $ do # step <- transfer False (||) s  dstep <- delay False step # memo (liftA2 (/=) step dstep)  Example:   do  smp <- start $ do  cnt <- stateful 0 (+1) ' tick <- until ((>=3) <$> cnt) & return $ liftA2 (,) cnt tick  res <- replicateM 6 smp  print res Output: > [(0,False),(1,False),(2,False),(3,True),(4,False),(5,False)] the boolean input signal =a one-shot signal true only the first time the input is true =Override the clock used in a generator. Note that clocks don't E interact unless one is used in the definition of the other, i.e. it D is possible to provide a fast clock within a generator with a slow @ associated clock. It is equivalent to the following function:  - withClock s g t_start s_clock = g t_start s /For instance, the following equivalence holds: 1 withClock (pure False) (stateful x f) == pure x Equivalent to withClock (pure True), but more efficient. <A signal that can be directly fed through the sink function @ returned. This can be used to attach the network to the outer @ world. The signal always yields the value last written to the D sink. In other words, if the sink is written less frequently than A the network sampled, the output remains the same during several B samples. If values are pushed in the sink more frequently, only 8 the last one before sampling is visible on the output.  Example:   do  (sig,snk) <- external 4  smp <- start (return sig)  r1 <- smp  r2 <- smp  snk 7  r3 <- smp  snk 9  snk 2  r4 <- smp  print [r1,r2,r3,r4] Output:  [4,4,7,2] initial value )the signal and an IO function to feed it ?An event-like signal that can be fed through the sink function A returned. The signal carries a list of values fed in since the ? last sampling (always synchronised to the top-level samplings < regardless of any associated clock), i.e. it is constantly [] if C the sink is never invoked. The order of elements is reversed, so B the last value passed to the sink is the head of the list. Note  that unlike  . this function only returns a generator to be C used within the expression constructing the top-level stream, and ' this generator can only be used once.  Example:   do  (gen,snk) <- externalMulti  smp <- start gen  r1 <- smp  snk 7  r2 <- smp  r3 <- smp  snk 9  snk 2  r4 <- smp  print [r1,r2,r3,r4] Output:  [[],[7],[],[2,9]] 9a generator for the event signal and the associated sink @A pure stateful signal. The initial state is the first output, A and every subsequent state is derived from the preceding one by C applying a pure transformation. It is affected by the associated  clock like 0: no transformation is performed in the absence ( of a tick; see the example at the top.  Example:   do ( smp <- start (stateful "x" ('x':))  res <- replicateM 5 smp  print res Output: ! ["x","xx","xxx","xxxx","xxxxx"] initial state state transformation =A stateful transfer function. The current input affects the D current output, i.e. the initial state given in the first argument C is considered to appear before the first output, and can never be A observed, and subsequent states are determined by combining the C preceding state with the current output of the input signal using E the function supplied. It is affected by the associated clock like  ;: no transformation is performed in the absence of a tick;  see the example at the top.  Example:   do  smp <- start $ do  cnt <- stateful 1 (+1)  transfer 10 (+) cnt  res <- replicateM 5 smp  print res Output:  [11,13,16,20,25] initial internal state state updater function  input signal A variation of  with two input signals. initial internal state state updater function input signal 1 input signal 2 A variation of  with three input signals. initial internal state state updater function input signal 1 input signal 2 input signal 3 A variation of  with four input signals. initial internal state state updater function input signal 1 input signal 2 input signal 3 input signal 4 An IO action executed in the  monad. Can be used as  liftIO. AA signal that executes a given IO action once at every sampling. >In essence, this combinator provides cooperative multitasking D capabilities, and its primary purpose is to assist library writers D in wrapping effectful APIs as conceptually pure signals. If there = are several effectful signals in the system, their order of 5 execution is undefined and should not be relied on.  Example:   do  smp <- start $ do % ref <- execute $ newIORef 0  effectful $ do  x <- readIORef ref , putStrLn $ "Count: " ++ show x # writeIORef ref $! x+1  return ()  replicateM_ 5 smp Output:   Count: 0  Count: 1  Count: 2  Count: 3  Count: 4 ,Another example (requires mersenne-random):   do B smp <- start $ effectful $ return randomIO :: IO (IO Double)  res <- replicateM 5 smp  print res Output: c [0.12067753390401374,0.8658877349182655,0.7159264443196786,0.1756941896012891,0.9513646060896676] %the action to be executed repeatedly <A signal that executes a parametric IO action once at every A sampling. The parameter is supplied by another signal at every  sampling step. %the action to be executed repeatedly parameter signal Like ", but with two parameter signals. %the action to be executed repeatedly parameter signal 1 parameter signal 2 Like $, but with three parameter signals. %the action to be executed repeatedly parameter signal 1 parameter signal 2 parameter signal 3 Like #, but with four parameter signals. %the action to be executed repeatedly parameter signal 1 parameter signal 2 parameter signal 3 parameter signal 4 e4Error message for unimplemented instance functions.     $f9The phases every signal goes through during a superstep. gh?A signal generator is the only source of stateful signals. It ) can be thought of as a function of type Nat -> Signal p -> a, : where the result is an arbitrary data structure that can E potentially contain new signals, the first argument is the creation D time of these new signals, and the second is a globally accessible  input signal. It exposes the U interface, which makes it @ possible to define signals in terms of each other. Unlike the B simple variant, the denotation of signal generators differs from : that of signals. We will use the following notation for  generators:   g = <|g0 g1 g2 ...|> DJust like signals, generators behave as functions of time, but they % can also refer to the input signal:  / g t_start s_input = [g0,g1,g2,...] !! t_start BThe conceptual difference between the two notions is that signals B are passed a sampling time, while generators expect a start time = that will be the creation time of all the freshly generated % signals in the resulting structure. ijk>A dynamic set of actions to update a network without breaking  consistency. ;A signal represents a value changing over time. It can be " thought of as a function of type Nat -> a, where the argument is  the sampling time, and the ] instance agrees with the @ intuition (bind corresponds to extracting the current sample). D Signals and the values they carry are denoted the following way in  the documentation:   s = <<s0 s1 s2 ...>> This says that s is a signal that reads s0 during the first  sampling, s15 during the second and so on. You can also think of  s as the following function:  ) s t_sample = [s0,s1,s2,...] !! t_sample @Signals are constrained to be sampled sequentially, there is no A random access. The only way to observe their output is through  . lEmbedding a signal into an `! environment. Repeated calls to E the computation returned cause the whole network to be updated, and E the current sample of the top-level signal is produced as a result. E The computation accepts a global parameter that will be distributed A to all signals. For instance, this can be the time step, if we A want to model continuous-time signals. 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.  Example:   do $ smp <- start (stateful 10 (+)) ! res <- forM [5,3,2,9,4] smp  print res Output:  [10,15,18,20,29] &the generator of the top-level signal %the computation to sample the signal m$Performing the two-phase superstep. n<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 1 combinator is the elementary building block for E adding state to the signal network by constructing delayed versions > of a signal that emit a given value at creation time and the + previous output of the signal afterwards (-- is undefined):  ( delay x0 s = <| <<x0 s0 s1 s2 s3 ...>> ( <<-- x0 s1 s2 s3 ...>> ( <<-- -- x0 s2 s3 ...>> ( <<-- -- -- x0 s3 ...>>  ...  |> BIt can be thought of as the following function (which should also ' make it clear why the return value is ):  % delay x0 s t_start s_input t_sample  | t_start == t_sample = x0 * | t_start < t_sample = s (t_sample-1) 7 | otherwise = error \"Premature sample!\" +The way signal generators are extracted by  ensures that E the error can never happen. It is also clear that the behaviour of  1 is not affected in any way by the global input. Example (requires the DoRec extension):   do  smp <- start $ do - rec let fib'' = liftA2 (+) fib' fib # fib' <- delay 1 fib'' ! fib <- delay 1 fib'  return fib ) res <- replicateM 7 (smp undefined)  print res Output:  [1,1,2,3,5,8,13] initial output the signal to delay =A formal conversion from signals to signal generators, which E effectively allows for retrieving the current value of a previously @ created signal within a generator. This includes both signals B defined in an external scope as well as those created earlier in D the same generator. It can be modelled by the following function: ( snapshot s t_start s_input = s t_start oAuxiliary function. ?A reactive signal that takes the value to output from a signal C generator carried by its input with the sampling time provided as @ the start time for the generated structure. It is possible to ? create new signals in the monad, which is the key to defining  dynamic data-flow networks.  " generator << <|x00 x01 x02 ...|> " <|x10 x11 x12 ...|> " <|x20 x21 x22 ...|>  ... ' >> = <| <<x00 x11 x22 ...>> ' <<x00 x11 x22 ...>> ' <<x00 x11 x22 ...>>  ...  |> 0It can be thought of as the following function:  D generator g t_start s_input t_sample = g t_sample t_sample s_input It has to live in the  monad, because it needs to C maintain an internal state to be able to cache the current sample D for efficiency reasons. However, this state is not carried between $ samples, therefore start time doesn't matter and can be ignored. D Also, even though it does not make use of the global input itself, ? part of its job is to distribute it among the newly generated  signals. -Refer to the longer example at the bottom of FRP.Elerea.Simple to  see how it can be used.  the signal of generators to run #the signal of generated structures :Memoising combinator. It can be used to cache results of B applicative combinators in case they are used in several places. % It is observationally equivalent to d in the   monad.   memo s = <|s s s s ...|> For instance, if s = f <$> s', then f will be recalculated  once for each sampling of s". This can be avoided by writing s  < - memo (f <$> s') instead. However,  incurs a small 4 overhead, therefore it should not be used blindly. BAll the functions defined in this module return memoised signals.  Just like ), it is independent of the global input. the signal to cache 4a signal observationally equivalent to the argument =A signal that is true exactly once: the first time the input C signal is true. Afterwards, it is constantly false, and it holds D no reference to the input signal. For instance (assuming the rest  of the input is constantly False):  2 until <<False False True True False True ...>> = L <| <<False False True False False False False False False False ...>> L << --- False True False False False False False False False ...>> L << --- --- True False False False False False False False ...>> L << --- --- --- True False False False False False False ...>> L << --- --- --- --- False True False False False False ...>> L << --- --- --- --- --- True False False False False ...>> L << --- --- --- --- --- --- False False False False ...>>  ...  |> DIt is observationally equivalent to the following expression (which  would hold onto s forever):   until s = do + step <- transfer False (const (||)) s  dstep <- delay False step # memo (liftA2 (/=) step dstep)  Example:   do  smp <- start $ do ! accum <- stateful 0 (+) * tick <- until ((>=10) <$> accum) ( return $ liftA2 (,) accum tick % res <- forM [4,1,3,5,2,8,6] smp  print res Output: K [(0,False),(4,False),(5,False),(8,False),(13,True),(15,False),(23,False)] the boolean input signal =a one-shot signal true only the first time the input is true BThe common input signal that is fed through the function returned  by , unless we are in an !ded generator. It is ' equivalent to the following function:  ! input t_start s_input = s_input  Example:   do  smp <- start $ do  sig <- input  return (sig*2) % res <- forM [4,1,3,5,2,8,6] smp  print res Output:  [8,2,6,10,4,16,12] !:Embed a generator with an overridden input signal. It is ' equivalent to the following function:  ) embed s g t_start s_input = g t_start s  Example:   do  smp <- start $ do  sig <- input  embed (sig*2) $ do  sig <- input  return (sig+1) % res <- forM [4,1,3,5,2,8,6] smp  print res Output:  [9,3,7,11,5,17,13] "<A signal that can be directly fed through the sink function @ returned. This can be used to attach the network to the outer E world. Note that this is optional, as all the input of the network B 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 #?An event-like signal that can be fed through the sink function A returned. The signal carries a list of values fed in since the ' last sampling, i.e. it is constantly [] if the sink is never @ invoked. The order of elements is reversed, so the last value ? passed to the sink is the head of the list. Note that unlike  ": this function only returns a generator to be used within < the expression constructing the top-level stream, and this " generator can only be used once. 9a generator for the event signal and the associated sink $BA direct stateful transformation of the input. The initial state D is the first output, and every following output is calculated from E the previous one and the value of the global parameter (which might  have been overridden by !).  Example:   do $ smp <- start (stateful "" (:))  res <- forM "olleh~" smp  print res Output: $ ["","o","lo","llo","ello","hello"] initial state state transformation %=A stateful transfer function. The current input affects the D current output, i.e. the initial state given in the first argument C is considered to appear before the first output, and can never be B observed. Every output is derived from the current value of the ; input signal, the global parameter (which might have been  overridden by !-) and the previous output. It is equivalent  to the following expression: BExample (assuming a delta time is passed to the sampling function  in each step):  1 integral x0 s = transfer x0 (\dt v x -> x+dt*v) Example for using the above:   do ( smp <- start (integral 3 (pure 2)) # res <- replicateM 7 (smp 0.1)  print res Output:  [3.2,3.4,3.6,3.8,4.0,4.2,4.4] initial internal state state updater function  input signal &A variation of % with two input signals. initial internal state state updater function input signal 1 input signal 2 'A variation of % with three input signals. initial internal state state updater function input signal 1 input signal 2 input signal 3 (A variation of % with four input signals. initial internal state state updater function input signal 1 input signal 2 input signal 3 input signal 4 )An IO action executed in the  monad. Can be used as  liftIO. *AA signal that executes a given IO action once at every sampling. >In essence, this combinator provides cooperative multitasking D capabilities, and its primary purpose is to assist library writers D in wrapping effectful APIs as conceptually pure signals. If there = are several effectful signals in the system, their order of 5 execution is undefined and should not be relied on.  Example:   do  act <- start $ do % ref <- execute $ newIORef 0  let accum n = do $ x <- readIORef ref 6 putStrLn $ "Accumulator: " ++ show x ' writeIORef ref $! x+n  return () $ effectful1 accum =<< input  forM_ [4,9,2,1,5] act Output:   Accumulator: 0  Accumulator: 4  Accumulator: 13  Accumulator: 15  Accumulator: 16 ,Another example (requires mersenne-random):   do 9 smp <- start $ effectful randomIO :: IO (IO Double)  res <- replicateM 5 smp  print res Output: c [0.12067753390401374,0.8658877349182655,0.7159264443196786,0.1756941896012891,0.9513646060896676] %the action to be executed repeatedly +<A signal that executes a parametric IO action once at every A sampling. The parameter is supplied by another signal at every  sampling step. %the action to be executed repeatedly parameter signal ,Like +", but with two parameter signals. %the action to be executed repeatedly parameter signal 1 parameter signal 2 -Like +$, but with three parameter signals. %the action to be executed repeatedly parameter signal 1 parameter signal 2 parameter signal 3 .Like +#, but with four parameter signals. %the action to be executed repeatedly parameter signal 1 parameter signal 2 parameter signal 3 parameter signal 4 p4Error message for unimplemented instance functions. qEquality test is impossible. rThe Show* instance is only defined for the sake of s...  !"#$%&'()*+,-."# !$%&'()*+,-. !"#$%&'()*+,-./0123456789:;</0123456789:;<0/123465789:;</0123456789:;<"t9The phases every signal goes through during a superstep. uv=?A signal generator is the only source of stateful signals. It ) can be thought of as a function of type Nat -> a , where the D result is an arbitrary data structure that can potentially contain A new signals, and the argument is the creation time of these new  signals. It exposes the U interface, which makes it D possible to define signals in terms of each other. The denotation E of signal generators happens to be the same as that of signals, but E this partly accidental (it does not hold in the other variants), so 1 we will use a separate notation for generators:   g = <|g0 g1 g2 ...|> ;Just like signals, generators behave as functions of time:  ' g t_start = [g0,g1,g2,...] !! t_start BThe conceptual difference between the two notions is that signals B are passed a sampling time, while generators expect a start time = that will be the creation time of all the freshly generated % signals in the resulting structure. wxy>A dynamic set of actions to update a network without breaking  consistency. >;A signal represents a value changing over time. It can be " thought of as a function of type Nat -> a, where the argument is  the sampling time, and the ] instance agrees with the @ intuition (bind corresponds to extracting the current sample). D Signals and the values they carry are denoted the following way in  the documentation:   s = <<s0 s1 s2 ...>> This says that s is a signal that reads s0 during the first  sampling, s15 during the second and so on. You can also think of  s as the following function:  ) s t_sample = [s0,s1,s2,...] !! t_sample @Signals are constrained to be sampled sequentially, there is no A random access. The only way to observe their output is through  ?. z?Embedding a signal into an `! environment. Repeated calls to E the computation returned cause the whole network to be updated, and = the current sample of the top-level signal is produced as a D result. This is the only way to extract a signal generator outside C the network, and it is equivalent to passing zero to the function * representing the generator. In general:  P replicateM n =<< start <|<<x0 x1 x2 x3 ...>> ...|> == take n [x0,x1,x2,x3,...]  Example:   do $ smp <- start (stateful 3 (+2))  res <- replicateM 5 smp  print res Output:  [3,5,7,9,11] &the generator of the top-level signal %the computation to sample the signal {$Performing the two-phase superstep. |<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 @1 combinator is the elementary building block for E adding state to the signal network by constructing delayed versions > of a signal that emit a given value at creation time and the + previous output of the signal afterwards (-- is undefined):  ( delay x0 s = <| <<x0 s0 s1 s2 s3 ...>> ( <<-- x0 s1 s2 s3 ...>> ( <<-- -- x0 s2 s3 ...>> ( <<-- -- -- x0 s3 ...>>  ...  |> BIt can be thought of as the following function (which should 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) 7 | otherwise = error \"Premature sample!\" +The way signal generators are extracted by B ensures that  the error can never happen. Example (requires the DoRec extension):   do  smp <- start $ do - rec let fib'' = liftA2 (+) fib' fib # fib' <- delay 1 fib'' ! fib <- delay 1 fib'  return fib  res <- replicateM 7 smp  print res Output:  [1,1,2,3,5,8,13]  initial output at creation time the signal to delay the delayed signal A=A formal conversion from signals to signal generators, which E effectively allows for retrieving the current value of a previously @ created signal within a generator. This includes both signals B defined in an external scope as well as those created earlier in C the same generator. In the model, it corresponds to the identity  function. }Auxiliary function. B?A reactive signal that takes the value to output from a signal C generator carried by its input with the sampling time provided as @ the start time for the generated structure. It is possible to ? create new signals in the monad, which is the key to defining  dynamic data-flow networks.  " generator << <|x00 x01 x02 ...|> " <|x10 x11 x12 ...|> " <|x20 x21 x22 ...|>  ... ' >> = <| <<x00 x11 x22 ...>> ' <<x00 x11 x22 ...>> ' <<x00 x11 x22 ...>>  ...  |> 0It 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 C maintain an internal state to be able to cache the current sample D for efficiency reasons. However, this state is not carried between $ samples, therefore start time doesn't matter and can be ignored. ?Refer to the longer example at the bottom to see how it can be  used.  the signal of generators to run #the signal of generated structures C:Memoising combinator. It can be used to cache results of B applicative combinators in case they are used in several places. % It is observationally equivalent to d in the =  monad.   memo s = <|s s s s ...|> For instance, if s = f <$> s', then f will be recalculated  once for each sampling of s". This can be avoided by writing s  < - memo (f <$> s') instead. However, C incurs a small 4 overhead, therefore it should not be used blindly. BAll the functions defined in this module return memoised signals. the signal to cache 4a signal observationally equivalent to the argument D=A signal that is true exactly once: the first time the input C signal is true. Afterwards, it is constantly false, and it holds D no reference to the input signal. For instance (assuming the rest  of the input is constantly False):  2 until <<False False True True False True ...>> = L <| <<False False True False False False False False False False ...>> L << --- False True False False False False False False False ...>> L << --- --- True False False False False False False False ...>> L << --- --- --- True False False False False False False ...>> L << --- --- --- --- False True False False False False ...>> L << --- --- --- --- --- True False False False False ...>> L << --- --- --- --- --- --- False False False False ...>>  ...  |> DIt is observationally equivalent to the following expression (which  would hold onto s forever):   until s = do # step <- transfer False (||) s  dstep <- delay False step # memo (liftA2 (/=) step dstep)  Example:   do  smp <- start $ do  cnt <- stateful 0 (+1) ' tick <- until ((>=3) <$> cnt) & return $ liftA2 (,) cnt tick  res <- replicateM 6 smp  print res Output: > [(0,False),(1,False),(2,False),(3,True),(4,False),(5,False)] the boolean input signal =a one-shot signal true only the first time the input is true E<A signal that can be directly fed through the sink function @ returned. This can be used to attach the network to the outer @ world. The signal always yields the value last written to the D sink. In other words, if the sink is written less frequently than A the network sampled, the output remains the same during several B samples. If values are pushed in the sink more frequently, only 8 the last one before sampling is visible on the output.  Example:   do  (sig,snk) <- external 4  smp <- start (return sig)  r1 <- smp  r2 <- smp  snk 7  r3 <- smp  snk 9  snk 2  r4 <- smp  print [r1,r2,r3,r4] Output:  [4,4,7,2] initial value )the signal and an IO function to feed it F?An event-like signal that can be fed through the sink function A returned. The signal carries a list of values fed in since the & last sampling, i.e. it is constantly [] if the sink is never @ invoked. The order of elements is reversed, so the last value ? passed to the sink is the head of the list. Note that unlike  E: this function only returns a generator to be used within < the expression constructing the top-level stream, and this " generator can only be used once.  Example:   do  (gen,snk) <- externalMulti  smp <- start gen  r1 <- smp  snk 7  r2 <- smp  r3 <- smp  snk 9  snk 2  r4 <- smp  print [r1,r2,r3,r4] Output:  [[],[7],[],[2,9]] 9a generator for the event signal and the associated sink G@A pure stateful signal. The initial state is the first output, A and every subsequent state is derived from the preceding one by ! applying a pure transformation.  Example:   do ( smp <- start (stateful "x" ('x':))  res <- replicateM 5 smp  print res Output: ! ["x","xx","xxx","xxxx","xxxxx"] initial state state transformation H=A stateful transfer function. The current input affects the D current output, i.e. the initial state given in the first argument C is considered to appear before the first output, and can never be A observed, and subsequent states are determined by combining the C preceding state with the current output of the input signal using  the function supplied.  Example:   do  smp <- start $ do  cnt <- stateful 1 (+1)  transfer 10 (+) cnt  res <- replicateM 5 smp  print res Output:  [11,13,16,20,25] initial internal state state updater function  input signal IA variation of H with two input signals. initial internal state state updater function input signal 1 input signal 2 JA variation of H with three input signals. initial internal state state updater function input signal 1 input signal 2 input signal 3 KA variation of H with four input signals. initial internal state state updater function input signal 1 input signal 2 input signal 3 input signal 4 LAn IO action executed in the = monad. Can be used as  liftIO. MAA signal that executes a given IO action once at every sampling. >In essence, this combinator provides cooperative multitasking D capabilities, and its primary purpose is to assist library writers D in wrapping effectful APIs as conceptually pure signals. If there = are several effectful signals in the system, their order of 5 execution is undefined and should not be relied on.  Example:   do  smp <- start $ do % ref <- execute $ newIORef 0  effectful $ do  x <- readIORef ref , putStrLn $ "Count: " ++ show x # writeIORef ref $! x+1  return ()  replicateM_ 5 smp Output:   Count: 0  Count: 1  Count: 2  Count: 3  Count: 4 ,Another example (requires mersenne-random):   do 9 smp <- start $ effectful randomIO :: IO (IO Double)  res <- replicateM 5 smp  print res Output: c [0.12067753390401374,0.8658877349182655,0.7159264443196786,0.1756941896012891,0.9513646060896676] %the action to be executed repeatedly N<A signal that executes a parametric IO action once at every A sampling. The parameter is supplied by another signal at every  sampling step. %the action to be executed repeatedly parameter signal OLike N", but with two parameter signals. %the action to be executed repeatedly parameter signal 1 parameter signal 2 PLike N$, but with three parameter signals. %the action to be executed repeatedly parameter signal 1 parameter signal 2 parameter signal 3 QLike N#, but with four parameter signals. %the action to be executed repeatedly parameter signal 1 parameter signal 2 parameter signal 3 parameter signal 4 ~4Error message for unimplemented instance functions. Equality test is impossible. 9The Show instance is only defined for the sake of Num... =>?@ABCDEFGHIJKLMNOPQ>=?EF@ABCDGHIJKLMNOPQ=>?@ABCDEFGHIJKLMNOPQ             !"        #$%&'()*+,-./0123456789#$%()*05679:;<=#$%()*05679:;> elerea-2.7.0FRP.Elerea.Simple.PureFRP.Elerea.ClockedFRP.Elerea.ParamFRP.Elerea.Simple FRP.ElereabaseGHC.Baseuntil SignalGenSignalstartdelaysnapshot generatormemo withClockglobalexternal externalMultistatefultransfer transfer2 transfer3 transfer4execute effectful effectful1 effectful2 effectful3 effectful4inputembedfromListtoListPhaseUpdatedReadyControl.Monad.FixMonadFixSGunSG UpdatePoolUpdateUClkUSig UpdateActionMonadS getUpdateghc-prim GHC.TypesIO superstep addSignalmemoisereturnunimp $fEqSignal $fShowSignalGHC.NumNum