{-# OPTIONS_HADDOCK hide #-}
module ForSyDe.Atom.MoC.DE.React.LF where

import           ForSyDe.Atom.MoC.DE.React.Core
import           ForSyDe.Atom.MoC.DE.React.Lib
import qualified ForSyDe.Atom.MoC.SY.Clocked as SYC
import           ForSyDe.Atom.MoC.TimeStamp
import           ForSyDe.Atom.Utility.Tuple ((><), (><<), (><<<))

-- CLOCKS --

-- | The equivalent of a timer set to period @0@ in LF. It triggers once at the
-- beginning of the execution and then it never triggers again.
timer0 :: Signal ()
timer0 :: Signal ()
timer0 = () -> Signal ()
forall t a. (Num t, Ord t) => a -> SignalBase t a
instant ()

-- | A timer signal generator
timer :: TimeStamp -- ^ period
      -> Signal () -- ^ timer signal
timer :: TimeStamp -> Signal ()
timer period :: TimeStamp
period = ([()] -> [()]) -> (TimeStamp, ()) -> Signal ()
forall t b1.
(Num t, Ord t) =>
([b1] -> [b1]) -> (t, b1) -> SignalBase t b1
generate1 [()] -> [()]
forall a. a -> a
id (TimeStamp
period,())

-- | Like 'timer', but you can specify an initial phase.
timer' :: TimeStamp -- ^ phase
       -> TimeStamp -- ^ period
       -> Signal () -- ^ timer signal
timer' :: TimeStamp -> TimeStamp -> Signal ()
timer' phase :: TimeStamp
phase period :: TimeStamp
period = TimeStamp -> () -> Signal () -> Signal ()
forall t a.
(Num t, Ord t) =>
t -> a -> SignalBase t a -> SignalBase t a
delay TimeStamp
phase () (Signal () -> Signal ()) -> Signal () -> Signal ()
forall a b. (a -> b) -> a -> b
$ TimeStamp -> Signal ()
timer TimeStamp
period

-- ACTIONS

-- | A delayed action is simply a delayed signal. In ForSyDe the initial value is
-- /mandatory/. If there is a notion of /unknown/, this has to be captured by the
-- domain @a@ of the event (i.e. \"one layer below\").
actionD :: TimeStamp -> Signal a -> Signal a 
actionD :: TimeStamp -> Signal a -> Signal a
actionD = TimeStamp -> Signal a -> Signal a
forall t a. (Num t, Ord t) => t -> SignalBase t a -> SignalBase t a
unsafeDelay

-- SYNC UTILITIES

states0inputs2 :: a -> b -> (a, b)
states0inputs2 = (,)
states0inputs3 :: a -> b -> c -> (a, b, c)
states0inputs3 = (,,)
states0inputs4 :: a -> b -> c -> d -> (a, b, c, d)
states0inputs4 = (,,,)
states1inputs1 :: b2
-> SignalBase t b2
-> SignalBase t b1
-> (SignalBase t b1, SignalBase t b2)
states1inputs1 i :: b2
i s1 :: SignalBase t b2
s1 i1 :: SignalBase t b1
i1       = b2
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2)
forall t b2 b1.
(Num t, Ord t) =>
b2
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2)
syncAndObs11 b2
i SignalBase t b1
i1 SignalBase t b2
s1
states2inputs1 :: (b2, b3)
-> SignalBase t b2
-> SignalBase t b3
-> SignalBase t b1
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
states2inputs1 i :: (b2, b3)
i s1 :: SignalBase t b2
s1 s2 :: SignalBase t b3
s2 i1 :: SignalBase t b1
i1    = (b2, b3)
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t b2 b3 b1.
(Num t, Ord t) =>
(b2, b3)
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
syncAndObs12 (b2, b3)
i SignalBase t b1
i1 SignalBase t b2
s1 SignalBase t b3
s2
states3inputs1 :: (b2, b3, b4)
-> SignalBase t b2
-> SignalBase t b3
-> SignalBase t b4
-> SignalBase t b1
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
states3inputs1 i :: (b2, b3, b4)
i s1 :: SignalBase t b2
s1 s2 :: SignalBase t b3
s2 s3 :: SignalBase t b4
s3 i1 :: SignalBase t b1
i1 = (b2, b3, b4)
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> SignalBase t b4
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall t b2 b3 b4 b1.
(Num t, Ord t) =>
(b2, b3, b4)
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> SignalBase t b4
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
syncAndObs13 (b2, b3, b4)
i SignalBase t b1
i1 SignalBase t b2
s1 SignalBase t b3
s2 SignalBase t b4
s3
states1inputs2 :: b3
-> SignalBase t b3
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
states1inputs2 i :: b3
i s1 :: SignalBase t b3
s1 i1 :: SignalBase t b1
i1 i2 :: SignalBase t b2
i2    = b3
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t b3 b1 b2.
(Num t, Ord t) =>
b3
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
syncAndObs21 b3
i SignalBase t b1
i1 SignalBase t b2
i2 SignalBase t b3
s1
-- | Alias for 'syncAndObs11'. Denotes which actions come from states (with persistent
-- values) and which come from other actions or inputs (instantaneous).
--
-- >>> let sts = read "{1@0,2@3,3@6,4@10,5@13}" :: Signal Int
-- >>> let ins = read "{1@3,2@4,3@5,4@6,5@13}"  :: Signal Int
-- >>> states1inputs1 0 sts ins
-- ({1@3s,2@4s,3@5s,4@6s,5@13s},{1@0s,2@3s,2@4s,2@5s,3@6s,4@10s,5@13s})
states2inputs2 :: (b3, b4)
-> SignalBase t b3
-> SignalBase t b4
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
states2inputs2 i :: (b3, b4)
i s1 :: SignalBase t b3
s1 s2 :: SignalBase t b4
s2 i1 :: SignalBase t b1
i1 i2 :: SignalBase t b2
i2 = (b3, b4)
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> SignalBase t b4
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall t b3 b4 b1 b2.
(Num t, Ord t) =>
(b3, b4)
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> SignalBase t b4
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
syncAndObs22 (b3, b4)
i SignalBase t b1
i1 SignalBase t b2
i2 SignalBase t b3
s1 SignalBase t b4
s2
states1inputs3 :: b4
-> SignalBase t b4
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
states1inputs3 i :: b4
i s1 :: SignalBase t b4
s1 i1 :: SignalBase t b1
i1 i2 :: SignalBase t b2
i2 i3 :: SignalBase t b3
i3 = b4
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> SignalBase t b4
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall t b4 b1 b2 b3.
(Num t, Ord t) =>
b4
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> SignalBase t b4
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
syncAndObs31 b4
i SignalBase t b1
i1 SignalBase t b2
i2 SignalBase t b3
i3 SignalBase t b4
s1

-- REACTIONS

reaction11 :: ([a1] -> [b1]) -> SignalBase Integer a1 -> SignalBase Integer b1
reaction11 = ([a1] -> [b1]) -> SignalBase Integer a1 -> SignalBase Integer b1
forall t a1 b1.
(Ord t, Num t) =>
([a1] -> [b1]) -> SignalBase t a1 -> SignalBase t b1
comb11 
reaction12 :: ([a1] -> ([b1], [b2]))
-> SignalBase Integer a1
-> (SignalBase Integer b1, SignalBase Integer b2)
reaction12 = ([a1] -> ([b1], [b2]))
-> SignalBase Integer a1
-> (SignalBase Integer b1, SignalBase Integer b2)
forall t a1 b1 b2.
(Num t, Ord t) =>
([a1] -> ([b1], [b2]))
-> SignalBase t a1 -> (SignalBase t b1, SignalBase t b2)
comb12  
reaction13 :: ([a1] -> ([b1], [b2], [b3]))
-> SignalBase Integer a1
-> (SignalBase Integer b1, SignalBase Integer b2,
    SignalBase Integer b3)
reaction13 = ([a1] -> ([b1], [b2], [b3]))
-> SignalBase Integer a1
-> (SignalBase Integer b1, SignalBase Integer b2,
    SignalBase Integer b3)
forall t a1 b1 b2 b3.
(Num t, Ord t) =>
([a1] -> ([b1], [b2], [b3]))
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
comb13 
reaction14 :: ([a1] -> ([b1], [b2], [b3], [b4]))
-> SignalBase Integer a1
-> (SignalBase Integer b1, SignalBase Integer b2,
    SignalBase Integer b3, SignalBase Integer b4)
reaction14 = ([a1] -> ([b1], [b2], [b3], [b4]))
-> SignalBase Integer a1
-> (SignalBase Integer b1, SignalBase Integer b2,
    SignalBase Integer b3, SignalBase Integer b4)
forall t a1 b1 b2 b3 b4.
(Num t, Ord t) =>
([a1] -> ([b1], [b2], [b3], [b4]))
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
comb14 
reaction21 :: ([a1] -> [a2] -> [b1])
-> (SignalBase t a1, SignalBase t a2) -> SignalBase t b1
reaction21 f :: [a1] -> [a2] -> [b1]
f = (SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1)
-> (SignalBase t a1, SignalBase t a2) -> SignalBase t b1
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
(><) (([a1] -> [a2] -> [b1])
-> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
forall t a1 a2 b1.
(Ord t, Num t) =>
([a1] -> [a2] -> [b1])
-> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
comb21 [a1] -> [a2] -> [b1]
f)
-- | Alias for 'comb22', tupled version, that can be chained directly from a
-- @statesXinputsY@ "utility", see 'states2inputs2'.
--
-- >>> let sts = read "{1@0,2@3,3@6,4@10,5@13}" :: Signal Int
-- >>> let ins = read "{1@3,2@4,3@5,4@6,5@13}"  :: Signal Int
-- >>> reaction21 (\a b -> [sum a + sum b]) $ states1inputs1 0 sts ins
-- {1@0s,3@3s,4@4s,5@5s,7@6s,4@10s,10@13s}
reaction22 :: ([a1] -> [a2] -> ([b1], [b2]))
-> (SignalBase t a1, SignalBase t a2)
-> (SignalBase t b1, SignalBase t b2)
reaction22 f :: [a1] -> [a2] -> ([b1], [b2])
f = (SignalBase t a1
 -> SignalBase t a2 -> (SignalBase t b1, SignalBase t b2))
-> (SignalBase t a1, SignalBase t a2)
-> (SignalBase t b1, SignalBase t b2)
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
(><) (([a1] -> [a2] -> ([b1], [b2]))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
forall t a1 a2 b1 b2.
(Num t, Ord t) =>
([a1] -> [a2] -> ([b1], [b2]))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
comb22 [a1] -> [a2] -> ([b1], [b2])
f)
reaction23 :: ([a1] -> [a2] -> ([b1], [b2], [b3]))
-> (SignalBase t a1, SignalBase t a2)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
reaction23 f :: [a1] -> [a2] -> ([b1], [b2], [b3])
f = (SignalBase t a1
 -> SignalBase t a2
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3))
-> (SignalBase t a1, SignalBase t a2)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
(><) (([a1] -> [a2] -> ([b1], [b2], [b3]))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a1 a2 b1 b2 b3.
(Num t, Ord t) =>
([a1] -> [a2] -> ([b1], [b2], [b3]))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
comb23 [a1] -> [a2] -> ([b1], [b2], [b3])
f)
reaction24 :: ([a1] -> [a2] -> ([b1], [b2], [b3], [b4]))
-> (SignalBase t a1, SignalBase t a2)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
reaction24 f :: [a1] -> [a2] -> ([b1], [b2], [b3], [b4])
f = (SignalBase t a1
 -> SignalBase t a2
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
     SignalBase t b4))
-> (SignalBase t a1, SignalBase t a2)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
(><) (([a1] -> [a2] -> ([b1], [b2], [b3], [b4]))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall t a1 a2 b1 b2 b3 b4.
(Num t, Ord t) =>
([a1] -> [a2] -> ([b1], [b2], [b3], [b4]))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
comb24 [a1] -> [a2] -> ([b1], [b2], [b3], [b4])
f)
reaction31 :: ([a1] -> [a2] -> [a3] -> [b1])
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3)
-> SignalBase t b1
reaction31 f :: [a1] -> [a2] -> [a3] -> [b1]
f = (SignalBase t a1
 -> SignalBase t a2 -> SignalBase t a3 -> SignalBase t b1)
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3)
-> SignalBase t b1
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
(><<) (([a1] -> [a2] -> [a3] -> [b1])
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
forall t a1 a2 a3 b1.
(Num t, Ord t) =>
([a1] -> [a2] -> [a3] -> [b1])
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
comb31 [a1] -> [a2] -> [a3] -> [b1]
f)
reaction32 :: ([a1] -> [a2] -> [a3] -> ([b1], [b2]))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3)
-> (SignalBase t b1, SignalBase t b2)
reaction32 f :: [a1] -> [a2] -> [a3] -> ([b1], [b2])
f = (SignalBase t a1
 -> SignalBase t a2
 -> SignalBase t a3
 -> (SignalBase t b1, SignalBase t b2))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3)
-> (SignalBase t b1, SignalBase t b2)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
(><<) (([a1] -> [a2] -> [a3] -> ([b1], [b2]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2)
forall t a1 a2 a3 b1 b2.
(Num t, Ord t) =>
([a1] -> [a2] -> [a3] -> ([b1], [b2]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2)
comb32 [a1] -> [a2] -> [a3] -> ([b1], [b2])
f)
reaction33 :: ([a1] -> [a2] -> [a3] -> ([b1], [b2], [b3]))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
reaction33 f :: [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3])
f = (SignalBase t a1
 -> SignalBase t a2
 -> SignalBase t a3
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
(><<) (([a1] -> [a2] -> [a3] -> ([b1], [b2], [b3]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a1 a2 a3 b1 b2 b3.
(Num t, Ord t) =>
([a1] -> [a2] -> [a3] -> ([b1], [b2], [b3]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
comb33 [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3])
f)
reaction34 :: ([a1] -> [a2] -> [a3] -> ([b1], [b2], [b3], [b4]))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
reaction34 f :: [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3], [b4])
f = (SignalBase t a1
 -> SignalBase t a2
 -> SignalBase t a3
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
     SignalBase t b4))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
(><<) (([a1] -> [a2] -> [a3] -> ([b1], [b2], [b3], [b4]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall t a1 a2 a3 b1 b2 b3 b4.
(Num t, Ord t) =>
([a1] -> [a2] -> [a3] -> ([b1], [b2], [b3], [b4]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
comb34 [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3], [b4])
f)
reaction41 :: ([a1] -> [a2] -> [a3] -> [a4] -> [b1])
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
-> SignalBase t b1
reaction41 f :: [a1] -> [a2] -> [a3] -> [a4] -> [b1]
f = (SignalBase t a1
 -> SignalBase t a2
 -> SignalBase t a3
 -> SignalBase t a4
 -> SignalBase t b1)
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
-> SignalBase t b1
forall t1 t2 t3 t4 t5.
(t1 -> t2 -> t3 -> t4 -> t5) -> (t1, t2, t3, t4) -> t5
(><<<) (([a1] -> [a2] -> [a3] -> [a4] -> [b1])
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> SignalBase t b1
forall t a1 a2 a3 a4 b1.
(Num t, Ord t) =>
([a1] -> [a2] -> [a3] -> [a4] -> [b1])
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> SignalBase t b1
comb41 [a1] -> [a2] -> [a3] -> [a4] -> [b1]
f)
reaction42 :: ([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2]))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
-> (SignalBase t b1, SignalBase t b2)
reaction42 f :: [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2])
f = (SignalBase t a1
 -> SignalBase t a2
 -> SignalBase t a3
 -> SignalBase t a4
 -> (SignalBase t b1, SignalBase t b2))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
-> (SignalBase t b1, SignalBase t b2)
forall t1 t2 t3 t4 t5.
(t1 -> t2 -> t3 -> t4 -> t5) -> (t1, t2, t3, t4) -> t5
(><<<) (([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> (SignalBase t b1, SignalBase t b2)
forall t a1 a2 a3 a4 b1 b2.
(Num t, Ord t) =>
([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> (SignalBase t b1, SignalBase t b2)
comb42 [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2])
f)
reaction43 :: ([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3]))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
reaction43 f :: [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3])
f = (SignalBase t a1
 -> SignalBase t a2
 -> SignalBase t a3
 -> SignalBase t a4
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t1 t2 t3 t4 t5.
(t1 -> t2 -> t3 -> t4 -> t5) -> (t1, t2, t3, t4) -> t5
(><<<) (([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a1 a2 a3 a4 b1 b2 b3.
(Num t, Ord t) =>
([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
comb43 [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3])
f)
reaction44 :: ([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3], [b4]))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
reaction44 f :: [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3], [b4])
f = (SignalBase t a1
 -> SignalBase t a2
 -> SignalBase t a3
 -> SignalBase t a4
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
     SignalBase t b4))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall t1 t2 t3 t4 t5.
(t1 -> t2 -> t3 -> t4 -> t5) -> (t1, t2, t3, t4) -> t5
(><<<) (([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3], [b4]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall t a1 a2 a3 a4 b1 b2 b3 b4.
(Num t, Ord t) =>
([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3], [b4]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
comb44 [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3], [b4])
f)


--------------- TEST -----------------

reactor1 :: TimeStamp -> Signal Int -> Signal Int
reactor1 :: TimeStamp -> Signal Int -> Signal Int
reactor1 period :: TimeStamp
period x :: Signal Int
x = Signal Int
y
  where
    t :: Signal ()
t     = TimeStamp -> Signal ()
timer TimeStamp
period
    count :: Signal Int
count = (Int -> [()] -> Int) -> Int -> Signal () -> Signal Int
forall t b1 a1.
(Num t, Ord t) =>
(b1 -> [a1] -> b1) -> b1 -> SignalBase t a1 -> SignalBase t b1
state11 (\s :: Int
s _ -> Int
s Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1) 0 Signal ()
t
    a :: Signal Int
a     = TimeStamp -> Signal Int -> Signal Int
forall a. TimeStamp -> Signal a -> Signal a
actionD (Integer -> TimeStamp
milisec 200) Signal Int
count
    y :: Signal Int
y     = ([Int] -> [Int] -> [Int]) -> (Signal Int, Signal Int) -> Signal Int
forall t a1 a2 b1.
(Ord t, Num t) =>
([a1] -> [a2] -> [b1])
-> (SignalBase t a1, SignalBase t a2) -> SignalBase t b1
reaction21 (\i1 :: [Int]
i1 i2 :: [Int]
i2 -> [[Int] -> Int
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [Int]
i1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [Int] -> Int
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [Int]
i2])
            ((Signal Int, Signal Int) -> Signal Int)
-> (Signal Int, Signal Int) -> Signal Int
forall a b. (a -> b) -> a -> b
$ Int -> Signal Int -> Signal Int -> (Signal Int, Signal Int)
forall t b2 b1.
(Num t, Ord t) =>
b2
-> SignalBase t b2
-> SignalBase t b1
-> (SignalBase t b1, SignalBase t b2)
states1inputs1 0 Signal Int
a Signal Int
x