{-# LANGUAGE PostfixOperators #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  ForSyDe.MoC.DE.React.Lib
-- Copyright   :  (c) George Ungureanu, KTH/EECS/ESY 2020
-- License     :  BSD-style (see the file LICENSE)
-- 
-- Maintainer  :  ugeorge@kth.se
-- Stability   :  experimental
-- Portability :  portable
--
-- This module provides a set of helpers for properly instantiating
-- process network patterns as process constructors.
-- 
-----------------------------------------------------------------------------
module ForSyDe.Atom.MoC.DE.React.Lib where

import qualified ForSyDe.Atom.ExB               as AE
import qualified ForSyDe.Atom.ExB.Absent        as AE
import ForSyDe.Atom.MoC (
  MoC(..), (-&>-), (-*<), (-*<<), (-*<<<),
  ctxt11, ctxt21, ctxt31, ctxt41, ctxt51, ctxt61, ctxt71, ctxt81, 
  ctxt12, ctxt22, ctxt32, ctxt42, ctxt52, ctxt62, ctxt72, ctxt82, 
  ctxt13, ctxt23, ctxt33, ctxt43, ctxt53, ctxt63, ctxt73, ctxt83, 
  ctxt14, ctxt24, ctxt34, ctxt44, ctxt54, ctxt64, ctxt74, ctxt84,
  ) 
import qualified ForSyDe.Atom.MoC               as MoC
import qualified ForSyDe.Atom.MoC.DE            as DE 
import           ForSyDe.Atom.MoC.DE.React.Core as RE
import qualified ForSyDe.Atom.MoC.SY            as SY
import qualified ForSyDe.Atom.MoC.SY.Clocked    as SYC
import           ForSyDe.Atom.MoC.Stream (Stream(..))
import           ForSyDe.Atom.Utility.Tuple

------- DOCTEST SETUP -------

-- $setup
-- >>> import ForSyDe.Atom.ExB.Absent (AbstExt(..))
-- >>> import ForSyDe.Atom.MoC.Stream (takeS)
-- >>> import ForSyDe.Atom.Utility.Plot

------- DELAY -------

-- | The @delay@ process "delays" a signal with one event, (see the
-- 'ForSyDe.Atom.MoC.delay' pattern). Any delayed signal starts from global 0.
--
-- >>> let s = readSignal "{1@2, 2@3, 3@6, 4@8, 5@9}" :: Signal Int
-- >>> delay 3 0 s
-- {0@0s,1@5s,2@6s,3@9s,4@11s,5@12s}
-- 
-- <<fig/moc-re-pattern-delay.png>>
delay :: (Num t, Ord t)
      => t              -- ^ time delay
      -> a              -- ^ initial value
      -> SignalBase t a -- ^ input signal
      -> SignalBase t a -- ^ output signal

delay :: t -> a -> SignalBase t a -> SignalBase t a
delay t :: t
t v :: a
v = SignalBase t a -> SignalBase t a -> SignalBase t a
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
MoC.delay ((t, a) -> SignalBase t a
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t
t, a
v))

-- | Similar to the previous, but this is the raw instantiation of the
-- 'ForSyDe.Atom.MoC.delay' pattern from "ForSyDe.Atom.MoC". It "borrows" the first
-- event from one signal and appends it at the head of another signal.
--
-- >>> let s1 = readSignal "{1@(-1), 2@2, 3@6, 4@8, 5@9}" :: Signal Int
-- >>> let s2 = readSignal "{3@2, 4@4, 5@5, 6@8, 7@9}" :: Signal Int
-- >>> delay' s1 s2
-- {1@-1s,3@5s,4@7s,5@8s,6@11s,7@12s}
--
-- <<fig/moc-re-pattern-delayp.png>>
delay' ::(Num t, Ord t)
       => SignalBase t a   -- ^ signal "borrowing" the initial event
       -> SignalBase t a   -- ^ input signal
       -> SignalBase t a   -- ^ output signal

delay' :: SignalBase t a -> SignalBase t a -> SignalBase t a
delay' = SignalBase t a -> SignalBase t a -> SignalBase t a
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
MoC.delay


-- | This process "delays" only the tags of a signal. The "usafe" prefix is a warning
-- that it does not express prefix behavior ('ForSyDe.Atom.MoC.->-'), which means that
-- in a feedback loop it will cause deadlock.
--
-- >>> let s = readSignal "{1@(-1), 2@2, 3@6, 4@8, 5@9}" :: Signal Int
-- >>> unsafeDelay 3 s
-- {1@2s,2@5s,3@9s,4@11s,5@12s}
-- 
-- <<fig/moc-re-pattern-udelay.png>>
unsafeDelay :: (Num t, Ord t)
            => t          -- ^ time delay
            -> SignalBase t a   -- ^ input signal
            -> SignalBase t a   -- ^ output signal
unsafeDelay :: t -> SignalBase t a -> SignalBase t a
unsafeDelay t :: t
t MoC.NullS = [Char] -> SignalBase t a
forall a. HasCallStack => [Char] -> a
error "[MoC.DE.RE] cannot delay a non-existing signal" 
unsafeDelay t :: t
t s :: SignalBase t a
s@(RE _ x :: a
x MoC.:- _) = (t, a) -> SignalBase t a
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t
t,a
x) SignalBase t a -> SignalBase t a -> SignalBase t a
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&- SignalBase t a
s
--------COMB --------

-- | @comb@ processes map a trigger-aware combinational function on signals and take
-- care of synchronization between input signals. 
-- 
-- Constructors: @comb[1-4][1-4]@.
--
-- >>> let s1 = instant 1
-- >>> let s2 = readSignal "{1@0, 2@2, 3@6, 4@8, 5@9}" :: RE.Signal Int
-- >>> comb11 (map (+1)) s2
-- {2@0s,3@2s,4@6s,5@8s,6@9s}
-- >>> let {f [a] [b] = ([a+b],[a-b]); f [a] []  = ([a],[a]); f [] [b]  = ([],[b]); f [] []  = ([],[])}
-- >>> comb22 f s1 s2
-- ({2@0s},{0@0s,2@2s,3@6s,4@8s,5@9s})
--
-- <<fig/moc-re-pattern-comb.png>>
comb22 :: (Num t, Ord t)
       => ([a1] -> [a2] -> ([b1], [b2]))     -- ^ function on values
       -> SignalBase t a1                    -- ^ first input signal
       -> SignalBase t a2                    -- ^ second input signal
       -> (SignalBase t b1, SignalBase t b2) -- ^ two output signals
comb11 :: (Ord t, Num t)
       => ([a1] -> [b1])
       -> SignalBase t a1 -> SignalBase t b1                                
comb12 :: (Num t, Ord t)
       => ([a1] -> ([b1], [b2]))
       -> SignalBase t a1 -> (SignalBase t b1, SignalBase t b2)                          
comb13 :: (Num t, Ord t)
       => ([a1] -> ([b1], [b2], [b3]))
       -> SignalBase t a1 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3)                      
comb14 :: (Num t, Ord t)
       => ([a1] -> ([b1], [b2], [b3], [b4]))
       -> SignalBase t a1 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3, SignalBase t b4)                  
comb21 :: (Ord t, Num t)
       => ([a1] -> [a2] -> [b1])
       -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1                          
comb23 :: (Num t, Ord t)
       => ([a1] -> [a2] -> ([b1], [b2], [b3]))
       -> SignalBase t a1 -> SignalBase t a2 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3)                
comb24 :: (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)            
comb31 :: (Num t, Ord t)
       => ([a1] -> [a2] -> [a3] -> [b1])
       -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3 -> SignalBase t b1                    
comb32 :: (Num t, Ord t)
       => ([a1] -> [a2] -> [a3] -> ([b1], [b2]))
       -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3 -> (SignalBase t b1, SignalBase t b2)              
comb33 :: (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)          
comb34 :: (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)     
comb41 :: (Num t, Ord t)
       => ([a1] -> [a2] -> [a3] -> [a4] -> [b1])
       -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3 -> SignalBase t a4 -> SignalBase t b1              
comb42 :: (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)        
comb43 :: (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)    
comb44 :: (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)

comb11 :: ([a1] -> [b1]) -> SignalBase t a1 -> SignalBase t b1
comb11 f :: [a1] -> [b1]
f s1 :: SignalBase t a1
s1 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool]
-> ([Bool] -> (Bool, [a1] -> ((), [b1])))
-> Stream (RE t (Bool, [a1] -> ((), [b1])))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> Bool -> () -> ([a1] -> [b1]) -> (Bool, [a1] -> ((), [b1]))
forall c p a b. c -> p -> (a -> b) -> (c, a -> (p, b))
ctxt11 ([Bool] -> Bool
forall a. [a] -> a
fromList1 [Bool]
t) () [a1] -> [b1]
f)
    Stream (RE t (Fun (RE t) a1 ((), [b1])))
-> SignalBase t a1 -> Stream (RE t ((), [b1]))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream (RE t (Ret (RE t) b1)) -> SignalBase t b1
forall (e :: * -> *) b.
MoC e =>
Stream (e (Ret e b)) -> Stream (e b)
-*)
comb12 :: ([a1] -> ([b1], [b2]))
-> SignalBase t a1 -> (SignalBase t b1, SignalBase t b2)
comb12 f :: [a1] -> ([b1], [b2])
f s1 :: SignalBase t a1
s1 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool]
-> ([Bool] -> (Bool, [a1] -> (((), [b1]), ((), [b2]))))
-> Stream (RE t (Bool, [a1] -> (((), [b1]), ((), [b2]))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> Bool
-> ((), ())
-> ([a1] -> ([b1], [b2]))
-> (Bool, [a1] -> (((), [b1]), ((), [b2])))
forall c p1 p2 a b1 b2.
c -> (p1, p2) -> (a -> (b1, b2)) -> (c, a -> ((p1, b1), (p2, b2)))
ctxt12 ([Bool] -> Bool
forall a. [a] -> a
fromList1 [Bool]
t) ((),()) [a1] -> ([b1], [b2])
f)
    Stream (RE t (Fun (RE t) a1 (((), [b1]), ((), [b2]))))
-> SignalBase t a1 -> Stream (RE t (((), [b1]), ((), [b2])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream (RE t (Ret (RE t) b1, Ret (RE t) b2))
-> (SignalBase t b1, SignalBase t b2)
forall (e :: * -> *) b1 b2.
MoC e =>
Stream (e (Ret e b1, Ret e b2)) -> (Stream (e b1), Stream (e b2))
-*<)
comb13 :: ([a1] -> ([b1], [b2], [b3]))
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
comb13 f :: [a1] -> ([b1], [b2], [b3])
f s1 :: SignalBase t a1
s1 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool]
-> ([Bool] -> (Bool, [a1] -> (((), [b1]), ((), [b2]), ((), [b3]))))
-> Stream
     (RE t (Bool, [a1] -> (((), [b1]), ((), [b2]), ((), [b3]))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> Bool
-> ((), (), ())
-> ([a1] -> ([b1], [b2], [b3]))
-> (Bool, [a1] -> (((), [b1]), ((), [b2]), ((), [b3])))
forall c p1 p2 p3 a b1 b2 b3.
c
-> (p1, p2, p3)
-> (a -> (b1, b2, b3))
-> (c, a -> ((p1, b1), (p2, b2), (p3, b3)))
ctxt13 ([Bool] -> Bool
forall a. [a] -> a
fromList1 [Bool]
t) ((),(),()) [a1] -> ([b1], [b2], [b3])
f)
    Stream (RE t (Fun (RE t) a1 (((), [b1]), ((), [b2]), ((), [b3]))))
-> SignalBase t a1
-> Stream (RE t (((), [b1]), ((), [b2]), ((), [b3])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream (RE t (Ret (RE t) b1, Ret (RE t) b2, Ret (RE t) b3))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall (e :: * -> *) b1 b2 b3.
MoC e =>
Stream (e (Ret e b1, Ret e b2, Ret e b3))
-> (Stream (e b1), Stream (e b2), Stream (e b3))
-*<<)
comb14 :: ([a1] -> ([b1], [b2], [b3], [b4]))
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
comb14 f :: [a1] -> ([b1], [b2], [b3], [b4])
f s1 :: SignalBase t a1
s1 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool]
-> ([Bool]
    -> (Bool,
        [a1] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))
-> Stream
     (RE
        t (Bool, [a1] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> Bool
-> ((), (), (), ())
-> ([a1] -> ([b1], [b2], [b3], [b4]))
-> (Bool, [a1] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))
forall c p1 p2 p3 p4 a b1 b2 b3 b4.
c
-> (p1, p2, p3, p4)
-> (a -> (b1, b2, b3, b4))
-> (c, a -> ((p1, b1), (p2, b2), (p3, b3), (p4, b4)))
ctxt14 ([Bool] -> Bool
forall a. [a] -> a
fromList1 [Bool]
t) ((),(),(),()) [a1] -> ([b1], [b2], [b3], [b4])
f)
    Stream
  (RE
     t (Fun (RE t) a1 (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))
-> SignalBase t a1
-> Stream (RE t (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream
  (RE t (Ret (RE t) b1, Ret (RE t) b2, Ret (RE t) b3, Ret (RE t) b4))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall (e :: * -> *) b1 b2 b3 b4.
MoC e =>
Stream (e (Ret e b1, Ret e b2, Ret e b3, Ret e b4))
-> (Stream (e b1), Stream (e b2), Stream (e b3), Stream (e b4))
-*<<<)
comb21 :: ([a1] -> [a2] -> [b1])
-> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
comb21 f :: [a1] -> [a2] -> [b1]
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool]
-> ([Bool] -> (Bool, [a1] -> (Bool, [a2] -> ((), [b1]))))
-> Stream (RE t (Bool, [a1] -> (Bool, [a2] -> ((), [b1]))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool)
-> ()
-> ([a1] -> [a2] -> [b1])
-> (Bool, [a1] -> (Bool, [a2] -> ((), [b1])))
forall c1 c2 p a1 a2 b.
(c1, c2) -> p -> (a1 -> a2 -> b) -> (c1, a1 -> (c2, a2 -> (p, b)))
ctxt21 ([Bool] -> (Bool, Bool)
forall b. [b] -> (b, b)
fromList2 [Bool]
t) () [a1] -> [a2] -> [b1]
f)
    Stream (RE t (Fun (RE t) a1 (Bool, [a2] -> ((), [b1]))))
-> SignalBase t a1 -> Stream (RE t (Bool, [a2] -> ((), [b1])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream (RE t (Fun (RE t) a2 ((), [b1])))
-> SignalBase t a2 -> Stream (RE t ((), [b1]))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream (RE t (Ret (RE t) b1)) -> SignalBase t b1
forall (e :: * -> *) b.
MoC e =>
Stream (e (Ret e b)) -> Stream (e b)
-*)
comb22 :: ([a1] -> [a2] -> ([b1], [b2]))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
comb22 f :: [a1] -> [a2] -> ([b1], [b2])
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool]
-> ([Bool]
    -> (Bool, [a1] -> (Bool, [a2] -> (((), [b1]), ((), [b2])))))
-> Stream
     (RE t (Bool, [a1] -> (Bool, [a2] -> (((), [b1]), ((), [b2])))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool)
-> ((), ())
-> ([a1] -> [a2] -> ([b1], [b2]))
-> (Bool, [a1] -> (Bool, [a2] -> (((), [b1]), ((), [b2]))))
forall ctxa ctxb a1 a2 b1 b2.
(ctxa, ctxa)
-> (ctxb, ctxb)
-> (a1 -> a2 -> (b1, b2))
-> (ctxa, a1 -> (ctxa, a2 -> ((ctxb, b1), (ctxb, b2))))
ctxt22 ([Bool] -> (Bool, Bool)
forall b. [b] -> (b, b)
fromList2 [Bool]
t) ((),()) [a1] -> [a2] -> ([b1], [b2])
f)
    Stream
  (RE t (Fun (RE t) a1 (Bool, [a2] -> (((), [b1]), ((), [b2])))))
-> SignalBase t a1
-> Stream (RE t (Bool, [a2] -> (((), [b1]), ((), [b2]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream (RE t (Fun (RE t) a2 (((), [b1]), ((), [b2]))))
-> SignalBase t a2 -> Stream (RE t (((), [b1]), ((), [b2])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream (RE t (Ret (RE t) b1, Ret (RE t) b2))
-> (SignalBase t b1, SignalBase t b2)
forall (e :: * -> *) b1 b2.
MoC e =>
Stream (e (Ret e b1, Ret e b2)) -> (Stream (e b1), Stream (e b2))
-*<)
comb23 :: ([a1] -> [a2] -> ([b1], [b2], [b3]))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
comb23 f :: [a1] -> [a2] -> ([b1], [b2], [b3])
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool]
-> ([Bool]
    -> (Bool,
        [a1] -> (Bool, [a2] -> (((), [b1]), ((), [b2]), ((), [b3])))))
-> Stream
     (RE
        t
        (Bool,
         [a1] -> (Bool, [a2] -> (((), [b1]), ((), [b2]), ((), [b3])))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool)
-> ((), (), ())
-> ([a1] -> [a2] -> ([b1], [b2], [b3]))
-> (Bool,
    [a1] -> (Bool, [a2] -> (((), [b1]), ((), [b2]), ((), [b3]))))
forall c1 c2 p1 p2 p3 a1 a2 b1 b2 b3.
(c1, c2)
-> (p1, p2, p3)
-> (a1 -> a2 -> (b1, b2, b3))
-> (c1, a1 -> (c2, a2 -> ((p1, b1), (p2, b2), (p3, b3))))
ctxt23 ([Bool] -> (Bool, Bool)
forall b. [b] -> (b, b)
fromList2 [Bool]
t) ((),(),()) [a1] -> [a2] -> ([b1], [b2], [b3])
f)
    Stream
  (RE
     t
     (Fun
        (RE t) a1 (Bool, [a2] -> (((), [b1]), ((), [b2]), ((), [b3])))))
-> SignalBase t a1
-> Stream
     (RE t (Bool, [a2] -> (((), [b1]), ((), [b2]), ((), [b3]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream (RE t (Fun (RE t) a2 (((), [b1]), ((), [b2]), ((), [b3]))))
-> SignalBase t a2
-> Stream (RE t (((), [b1]), ((), [b2]), ((), [b3])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream (RE t (Ret (RE t) b1, Ret (RE t) b2, Ret (RE t) b3))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall (e :: * -> *) b1 b2 b3.
MoC e =>
Stream (e (Ret e b1, Ret e b2, Ret e b3))
-> (Stream (e b1), Stream (e b2), Stream (e b3))
-*<<)
comb24 :: ([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 f :: [a1] -> [a2] -> ([b1], [b2], [b3], [b4])
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool]
-> ([Bool]
    -> (Bool,
        [a1]
        -> (Bool,
            [a2] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))
-> Stream
     (RE
        t
        (Bool,
         [a1]
         -> (Bool,
             [a2] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool)
-> ((), (), (), ())
-> ([a1] -> [a2] -> ([b1], [b2], [b3], [b4]))
-> (Bool,
    [a1]
    -> (Bool,
        [a2] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))
forall c1 c2 p1 p2 p3 p4 a1 a2 b1 b2 b3 b4.
(c1, c2)
-> (p1, p2, p3, p4)
-> (a1 -> a2 -> (b1, b2, b3, b4))
-> (c1, a1 -> (c2, a2 -> ((p1, b1), (p2, b2), (p3, b3), (p4, b4))))
ctxt24 ([Bool] -> (Bool, Bool)
forall b. [b] -> (b, b)
fromList2 [Bool]
t) ((),(),(),()) [a1] -> [a2] -> ([b1], [b2], [b3], [b4])
f)
    Stream
  (RE
     t
     (Fun
        (RE t)
        a1
        (Bool, [a2] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))
-> SignalBase t a1
-> Stream
     (RE
        t (Bool, [a2] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream
  (RE
     t (Fun (RE t) a2 (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))
-> SignalBase t a2
-> Stream (RE t (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream
  (RE t (Ret (RE t) b1, Ret (RE t) b2, Ret (RE t) b3, Ret (RE t) b4))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall (e :: * -> *) b1 b2 b3 b4.
MoC e =>
Stream (e (Ret e b1, Ret e b2, Ret e b3, Ret e b4))
-> (Stream (e b1), Stream (e b2), Stream (e b3), Stream (e b4))
-*<<<)
comb31 :: ([a1] -> [a2] -> [a3] -> [b1])
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
comb31 f :: [a1] -> [a2] -> [a3] -> [b1]
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool] -> SignalBase t a3 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a3
s3 SignalBase t [Bool]
-> ([Bool]
    -> (Bool, [a1] -> (Bool, [a2] -> (Bool, [a3] -> ((), [b1])))))
-> Stream
     (RE t (Bool, [a1] -> (Bool, [a2] -> (Bool, [a3] -> ((), [b1])))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool, Bool)
-> ()
-> ([a1] -> [a2] -> [a3] -> [b1])
-> (Bool, [a1] -> (Bool, [a2] -> (Bool, [a3] -> ((), [b1]))))
forall c1 c2 c3 p a1 a2 a3 b.
(c1, c2, c3)
-> p
-> (a1 -> a2 -> a3 -> b)
-> (c1, a1 -> (c2, a2 -> (c3, a3 -> (p, b))))
ctxt31 ([Bool] -> (Bool, Bool, Bool)
forall c. [c] -> (c, c, c)
fromList3 [Bool]
t) () [a1] -> [a2] -> [a3] -> [b1]
f)
    Stream
  (RE t (Fun (RE t) a1 (Bool, [a2] -> (Bool, [a3] -> ((), [b1])))))
-> SignalBase t a1
-> Stream (RE t (Bool, [a2] -> (Bool, [a3] -> ((), [b1]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream (RE t (Fun (RE t) a2 (Bool, [a3] -> ((), [b1]))))
-> SignalBase t a2 -> Stream (RE t (Bool, [a3] -> ((), [b1])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream (RE t (Fun (RE t) a3 ((), [b1])))
-> SignalBase t a3 -> Stream (RE t ((), [b1]))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a3
s3 Stream (RE t (Ret (RE t) b1)) -> SignalBase t b1
forall (e :: * -> *) b.
MoC e =>
Stream (e (Ret e b)) -> Stream (e b)
-*)
comb32 :: ([a1] -> [a2] -> [a3] -> ([b1], [b2]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2)
comb32 f :: [a1] -> [a2] -> [a3] -> ([b1], [b2])
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool] -> SignalBase t a3 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a3
s3 SignalBase t [Bool]
-> ([Bool]
    -> (Bool,
        [a1] -> (Bool, [a2] -> (Bool, [a3] -> (((), [b1]), ((), [b2]))))))
-> Stream
     (RE
        t
        (Bool,
         [a1] -> (Bool, [a2] -> (Bool, [a3] -> (((), [b1]), ((), [b2]))))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool, Bool)
-> ((), ())
-> ([a1] -> [a2] -> [a3] -> ([b1], [b2]))
-> (Bool,
    [a1] -> (Bool, [a2] -> (Bool, [a3] -> (((), [b1]), ((), [b2])))))
forall c ctxa ctxb a a1 a2 b1 b2.
(c, ctxa, ctxa)
-> (ctxb, ctxb)
-> (a -> a1 -> a2 -> (b1, b2))
-> (c, a -> (ctxa, a1 -> (ctxa, a2 -> ((ctxb, b1), (ctxb, b2)))))
ctxt32 ([Bool] -> (Bool, Bool, Bool)
forall c. [c] -> (c, c, c)
fromList3 [Bool]
t) ((),()) [a1] -> [a2] -> [a3] -> ([b1], [b2])
f)
    Stream
  (RE
     t
     (Fun
        (RE t)
        a1
        (Bool, [a2] -> (Bool, [a3] -> (((), [b1]), ((), [b2]))))))
-> SignalBase t a1
-> Stream
     (RE t (Bool, [a2] -> (Bool, [a3] -> (((), [b1]), ((), [b2])))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream
  (RE t (Fun (RE t) a2 (Bool, [a3] -> (((), [b1]), ((), [b2])))))
-> SignalBase t a2
-> Stream (RE t (Bool, [a3] -> (((), [b1]), ((), [b2]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream (RE t (Fun (RE t) a3 (((), [b1]), ((), [b2]))))
-> SignalBase t a3 -> Stream (RE t (((), [b1]), ((), [b2])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a3
s3 Stream (RE t (Ret (RE t) b1, Ret (RE t) b2))
-> (SignalBase t b1, SignalBase t b2)
forall (e :: * -> *) b1 b2.
MoC e =>
Stream (e (Ret e b1, Ret e b2)) -> (Stream (e b1), Stream (e b2))
-*<)
comb33 :: ([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 f :: [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3])
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool] -> SignalBase t a3 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a3
s3 SignalBase t [Bool]
-> ([Bool]
    -> (Bool,
        [a1]
        -> (Bool,
            [a2] -> (Bool, [a3] -> (((), [b1]), ((), [b2]), ((), [b3]))))))
-> Stream
     (RE
        t
        (Bool,
         [a1]
         -> (Bool,
             [a2] -> (Bool, [a3] -> (((), [b1]), ((), [b2]), ((), [b3]))))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool, Bool)
-> ((), (), ())
-> ([a1] -> [a2] -> [a3] -> ([b1], [b2], [b3]))
-> (Bool,
    [a1]
    -> (Bool,
        [a2] -> (Bool, [a3] -> (((), [b1]), ((), [b2]), ((), [b3])))))
forall c1 c2 c3 p1 p2 p3 a1 a2 a3 b1 b2 b3.
(c1, c2, c3)
-> (p1, p2, p3)
-> (a1 -> a2 -> a3 -> (b1, b2, b3))
-> (c1,
    a1 -> (c2, a2 -> (c3, a3 -> ((p1, b1), (p2, b2), (p3, b3)))))
ctxt33 ([Bool] -> (Bool, Bool, Bool)
forall c. [c] -> (c, c, c)
fromList3 [Bool]
t) ((),(),()) [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3])
f)
    Stream
  (RE
     t
     (Fun
        (RE t)
        a1
        (Bool,
         [a2] -> (Bool, [a3] -> (((), [b1]), ((), [b2]), ((), [b3]))))))
-> SignalBase t a1
-> Stream
     (RE
        t
        (Bool,
         [a2] -> (Bool, [a3] -> (((), [b1]), ((), [b2]), ((), [b3])))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream
  (RE
     t
     (Fun
        (RE t) a2 (Bool, [a3] -> (((), [b1]), ((), [b2]), ((), [b3])))))
-> SignalBase t a2
-> Stream
     (RE t (Bool, [a3] -> (((), [b1]), ((), [b2]), ((), [b3]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream (RE t (Fun (RE t) a3 (((), [b1]), ((), [b2]), ((), [b3]))))
-> SignalBase t a3
-> Stream (RE t (((), [b1]), ((), [b2]), ((), [b3])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a3
s3 Stream (RE t (Ret (RE t) b1, Ret (RE t) b2, Ret (RE t) b3))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall (e :: * -> *) b1 b2 b3.
MoC e =>
Stream (e (Ret e b1, Ret e b2, Ret e b3))
-> (Stream (e b1), Stream (e b2), Stream (e b3))
-*<<)
comb34 :: ([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 f :: [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3], [b4])
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool] -> SignalBase t a3 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a3
s3 SignalBase t [Bool]
-> ([Bool]
    -> (Bool,
        [a1]
        -> (Bool,
            [a2]
            -> (Bool,
                [a3] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))))
-> Stream
     (RE
        t
        (Bool,
         [a1]
         -> (Bool,
             [a2]
             -> (Bool,
                 [a3] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool, Bool)
-> ((), (), (), ())
-> ([a1] -> [a2] -> [a3] -> ([b1], [b2], [b3], [b4]))
-> (Bool,
    [a1]
    -> (Bool,
        [a2]
        -> (Bool,
            [a3] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))
forall c1 c2 c3 p1 p2 p3 p4 a1 a2 a3 b1 b2 b3 b4.
(c1, c2, c3)
-> (p1, p2, p3, p4)
-> (a1 -> a2 -> a3 -> (b1, b2, b3, b4))
-> (c1,
    a1
    -> (c2,
        a2 -> (c3, a3 -> ((p1, b1), (p2, b2), (p3, b3), (p4, b4)))))
ctxt34 ([Bool] -> (Bool, Bool, Bool)
forall c. [c] -> (c, c, c)
fromList3 [Bool]
t) ((),(),(),()) [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3], [b4])
f)
    Stream
  (RE
     t
     (Fun
        (RE t)
        a1
        (Bool,
         [a2]
         -> (Bool,
             [a3] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))))
-> SignalBase t a1
-> Stream
     (RE
        t
        (Bool,
         [a2]
         -> (Bool,
             [a3] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream
  (RE
     t
     (Fun
        (RE t)
        a2
        (Bool, [a3] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))
-> SignalBase t a2
-> Stream
     (RE
        t (Bool, [a3] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream
  (RE
     t (Fun (RE t) a3 (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))
-> SignalBase t a3
-> Stream (RE t (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a3
s3 Stream
  (RE t (Ret (RE t) b1, Ret (RE t) b2, Ret (RE t) b3, Ret (RE t) b4))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall (e :: * -> *) b1 b2 b3 b4.
MoC e =>
Stream (e (Ret e b1, Ret e b2, Ret e b3, Ret e b4))
-> (Stream (e b1), Stream (e b2), Stream (e b3), Stream (e b4))
-*<<<)
comb41 :: ([a1] -> [a2] -> [a3] -> [a4] -> [b1])
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> SignalBase t b1
comb41 f :: [a1] -> [a2] -> [a3] -> [a4] -> [b1]
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 s4 :: SignalBase t a4
s4 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool] -> SignalBase t a3 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a3
s3 SignalBase t [Bool] -> SignalBase t a4 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a4
s4 SignalBase t [Bool]
-> ([Bool]
    -> (Bool,
        [a1]
        -> (Bool, [a2] -> (Bool, [a3] -> (Bool, [a4] -> ((), [b1]))))))
-> Stream
     (RE
        t
        (Bool,
         [a1]
         -> (Bool, [a2] -> (Bool, [a3] -> (Bool, [a4] -> ((), [b1]))))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool, Bool, Bool)
-> ()
-> ([a1] -> [a2] -> [a3] -> [a4] -> [b1])
-> (Bool,
    [a1] -> (Bool, [a2] -> (Bool, [a3] -> (Bool, [a4] -> ((), [b1])))))
forall c1 c2 c3 c4 p a1 a2 a3 a4 b.
(c1, c2, c3, c4)
-> p
-> (a1 -> a2 -> a3 -> a4 -> b)
-> (c1, a1 -> (c2, a2 -> (c3, a3 -> (c4, a4 -> (p, b)))))
ctxt41 ([Bool] -> (Bool, Bool, Bool, Bool)
forall d. [d] -> (d, d, d, d)
fromList4 [Bool]
t) () [a1] -> [a2] -> [a3] -> [a4] -> [b1]
f)
    Stream
  (RE
     t
     (Fun
        (RE t)
        a1
        (Bool, [a2] -> (Bool, [a3] -> (Bool, [a4] -> ((), [b1]))))))
-> SignalBase t a1
-> Stream
     (RE t (Bool, [a2] -> (Bool, [a3] -> (Bool, [a4] -> ((), [b1])))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream
  (RE t (Fun (RE t) a2 (Bool, [a3] -> (Bool, [a4] -> ((), [b1])))))
-> SignalBase t a2
-> Stream (RE t (Bool, [a3] -> (Bool, [a4] -> ((), [b1]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream (RE t (Fun (RE t) a3 (Bool, [a4] -> ((), [b1]))))
-> SignalBase t a3 -> Stream (RE t (Bool, [a4] -> ((), [b1])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a3
s3 Stream (RE t (Fun (RE t) a4 ((), [b1])))
-> SignalBase t a4 -> Stream (RE t ((), [b1]))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a4
s4 Stream (RE t (Ret (RE t) b1)) -> SignalBase t b1
forall (e :: * -> *) b.
MoC e =>
Stream (e (Ret e b)) -> Stream (e b)
-*)
comb42 :: ([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 f :: [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2])
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 s4 :: SignalBase t a4
s4 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool] -> SignalBase t a3 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a3
s3 SignalBase t [Bool] -> SignalBase t a4 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a4
s4 SignalBase t [Bool]
-> ([Bool]
    -> (Bool,
        [a1]
        -> (Bool,
            [a2] -> (Bool, [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2])))))))
-> Stream
     (RE
        t
        (Bool,
         [a1]
         -> (Bool,
             [a2] -> (Bool, [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2])))))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool, Bool, Bool)
-> ((), ())
-> ([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2]))
-> (Bool,
    [a1]
    -> (Bool,
        [a2] -> (Bool, [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2]))))))
forall c1 c2 ctxa ctxb a1 a2 a3 a4 b1 b2.
(c1, c2, ctxa, ctxa)
-> (ctxb, ctxb)
-> (a1 -> a2 -> a3 -> a4 -> (b1, b2))
-> (c1,
    a1
    -> (c2,
        a2 -> (ctxa, a3 -> (ctxa, a4 -> ((ctxb, b1), (ctxb, b2))))))
ctxt42 ([Bool] -> (Bool, Bool, Bool, Bool)
forall d. [d] -> (d, d, d, d)
fromList4 [Bool]
t) ((),()) [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2])
f)
    Stream
  (RE
     t
     (Fun
        (RE t)
        a1
        (Bool,
         [a2] -> (Bool, [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2])))))))
-> SignalBase t a1
-> Stream
     (RE
        t
        (Bool,
         [a2] -> (Bool, [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2]))))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream
  (RE
     t
     (Fun
        (RE t)
        a2
        (Bool, [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2]))))))
-> SignalBase t a2
-> Stream
     (RE t (Bool, [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2])))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream
  (RE t (Fun (RE t) a3 (Bool, [a4] -> (((), [b1]), ((), [b2])))))
-> SignalBase t a3
-> Stream (RE t (Bool, [a4] -> (((), [b1]), ((), [b2]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a3
s3 Stream (RE t (Fun (RE t) a4 (((), [b1]), ((), [b2]))))
-> SignalBase t a4 -> Stream (RE t (((), [b1]), ((), [b2])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a4
s4 Stream (RE t (Ret (RE t) b1, Ret (RE t) b2))
-> (SignalBase t b1, SignalBase t b2)
forall (e :: * -> *) b1 b2.
MoC e =>
Stream (e (Ret e b1, Ret e b2)) -> (Stream (e b1), Stream (e b2))
-*<)
comb43 :: ([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 f :: [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3])
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 s4 :: SignalBase t a4
s4 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool] -> SignalBase t a3 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a3
s3 SignalBase t [Bool] -> SignalBase t a4 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a4
s4 SignalBase t [Bool]
-> ([Bool]
    -> (Bool,
        [a1]
        -> (Bool,
            [a2]
            -> (Bool,
                [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3])))))))
-> Stream
     (RE
        t
        (Bool,
         [a1]
         -> (Bool,
             [a2]
             -> (Bool,
                 [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3])))))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool, Bool, Bool)
-> ((), (), ())
-> ([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3]))
-> (Bool,
    [a1]
    -> (Bool,
        [a2]
        -> (Bool,
            [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3]))))))
forall c1 c2 c3 c4 p1 p2 p3 a1 a2 a3 a4 b1 b2 b3.
(c1, c2, c3, c4)
-> (p1, p2, p3)
-> (a1 -> a2 -> a3 -> a4 -> (b1, b2, b3))
-> (c1,
    a1
    -> (c2,
        a2 -> (c3, a3 -> (c4, a4 -> ((p1, b1), (p2, b2), (p3, b3))))))
ctxt43 ([Bool] -> (Bool, Bool, Bool, Bool)
forall d. [d] -> (d, d, d, d)
fromList4 [Bool]
t) ((),(),()) [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3])
f)
    Stream
  (RE
     t
     (Fun
        (RE t)
        a1
        (Bool,
         [a2]
         -> (Bool,
             [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3])))))))
-> SignalBase t a1
-> Stream
     (RE
        t
        (Bool,
         [a2]
         -> (Bool,
             [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3]))))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream
  (RE
     t
     (Fun
        (RE t)
        a2
        (Bool,
         [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3]))))))
-> SignalBase t a2
-> Stream
     (RE
        t
        (Bool,
         [a3] -> (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3])))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream
  (RE
     t
     (Fun
        (RE t) a3 (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3])))))
-> SignalBase t a3
-> Stream
     (RE t (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a3
s3 Stream (RE t (Fun (RE t) a4 (((), [b1]), ((), [b2]), ((), [b3]))))
-> SignalBase t a4
-> Stream (RE t (((), [b1]), ((), [b2]), ((), [b3])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a4
s4 Stream (RE t (Ret (RE t) b1, Ret (RE t) b2, Ret (RE t) b3))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall (e :: * -> *) b1 b2 b3.
MoC e =>
Stream (e (Ret e b1, Ret e b2, Ret e b3))
-> (Stream (e b1), Stream (e b2), Stream (e b3))
-*<<)
comb44 :: ([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 f :: [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3], [b4])
f s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 s4 :: SignalBase t a4
s4 =
  (SignalBase t a1 -> SignalBase t [Bool]
forall t a. (Ord t, Num t) => SignalBase t a -> SignalBase t [Bool]
detect SignalBase t a1
s1 SignalBase t [Bool] -> SignalBase t a2 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a2
s2 SignalBase t [Bool] -> SignalBase t a3 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a3
s3 SignalBase t [Bool] -> SignalBase t a4 -> SignalBase t [Bool]
forall t a.
(Ord t, Num t) =>
SignalBase t [Bool] -> SignalBase t a -> SignalBase t [Bool]
-?- SignalBase t a4
s4 SignalBase t [Bool]
-> ([Bool]
    -> (Bool,
        [a1]
        -> (Bool,
            [a2]
            -> (Bool,
                [a3]
                -> (Bool,
                    [a4] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))))
-> Stream
     (RE
        t
        (Bool,
         [a1]
         -> (Bool,
             [a2]
             -> (Bool,
                 [a3]
                 -> (Bool,
                     [a4] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))))
forall (f1 :: * -> *) (f2 :: * -> *) a b.
(Functor f1, Functor f2) =>
f1 (f2 a) -> (a -> b) -> f1 (f2 b)
-? (\t :: [Bool]
t -> (Bool, Bool, Bool, Bool)
-> ((), (), (), ())
-> ([a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3], [b4]))
-> (Bool,
    [a1]
    -> (Bool,
        [a2]
        -> (Bool,
            [a3]
            -> (Bool,
                [a4] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))))
forall c1 c2 c3 c4 p1 p2 p3 p4 a1 a2 a3 a4 b1 b2 b3 b4.
(c1, c2, c3, c4)
-> (p1, p2, p3, p4)
-> (a1 -> a2 -> a3 -> a4 -> (b1, b2, b3, b4))
-> (c1,
    a1
    -> (c2,
        a2
        -> (c3,
            a3 -> (c4, a4 -> ((p1, b1), (p2, b2), (p3, b3), (p4, b4))))))
ctxt44 ([Bool] -> (Bool, Bool, Bool, Bool)
forall d. [d] -> (d, d, d, d)
fromList4 [Bool]
t) ((),(),(),()) [a1] -> [a2] -> [a3] -> [a4] -> ([b1], [b2], [b3], [b4])
f)
    Stream
  (RE
     t
     (Fun
        (RE t)
        a1
        (Bool,
         [a2]
         -> (Bool,
             [a3]
             -> (Bool,
                 [a4] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))))
-> SignalBase t a1
-> Stream
     (RE
        t
        (Bool,
         [a2]
         -> (Bool,
             [a3]
             -> (Bool,
                 [a4] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a1
s1 Stream
  (RE
     t
     (Fun
        (RE t)
        a2
        (Bool,
         [a3]
         -> (Bool,
             [a4] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))))
-> SignalBase t a2
-> Stream
     (RE
        t
        (Bool,
         [a3]
         -> (Bool,
             [a4] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a2
s2 Stream
  (RE
     t
     (Fun
        (RE t)
        a3
        (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))))
-> SignalBase t a3
-> Stream
     (RE
        t (Bool, [a4] -> (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a3
s3 Stream
  (RE
     t (Fun (RE t) a4 (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4]))))
-> SignalBase t a4
-> Stream (RE t (((), [b1]), ((), [b2]), ((), [b3]), ((), [b4])))
forall (e :: * -> *) a b.
MoC e =>
Stream (e (Fun e a b)) -> Stream (e a) -> Stream (e b)
-*- SignalBase t a4
s4 Stream
  (RE t (Ret (RE t) b1, Ret (RE t) b2, Ret (RE t) b3, Ret (RE t) b4))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3,
    SignalBase t b4)
forall (e :: * -> *) b1 b2 b3 b4.
MoC e =>
Stream (e (Ret e b1, Ret e b2, Ret e b3, Ret e b4))
-> (Stream (e b1), Stream (e b2), Stream (e b3), Stream (e b4))
-*<<<)

------- GENERATE -------

generate1 :: (Num t, Ord t)
          =>  ([b1] -> [b1]) -> (t, b1)
          -> SignalBase t b1                                
-- | A signal generator based on a function and a kernel value. 
--
-- Constructors: @generate[1-3]@.
--
-- >>> let ns a b = (map (+1) a,map (+2) b)
-- >>> let (s1,s2) = generate2 ns ((3,1),(1,2))
-- >>> takeS 5 s1
-- {1@0,2@3,3@6,4@9,5@12}
-- >>> takeS 7 s2
-- {2@0,4@1,6@2,8@3,10@4,12@5,14@6}
--
-- <<fig/moc-re-pattern-generate.png>>
generate2 :: (Num t, Ord t)
          =>  ([b1] -> [b2] -> ([b1], [b2]))
          -- ^ function to generate next value
          -> ((t, b1), (t, b2))
          -- ^ kernel values tupled with their generation rate.
          -> (SignalBase t b1, SignalBase t b2) -- ^ generated signals
generate3 :: (Num t, Ord t)
          =>  ([b1] -> [b2] -> [b3] -> ([b1], [b2], [b3]))
          -> ((t, b1), (t, b2), (t, b3))
          -> (SignalBase t b1, SignalBase t b2, SignalBase t b3)                      

generate1 :: ([b1] -> [b1]) -> (t, b1) -> SignalBase t b1
generate1 ns :: [b1] -> [b1]
ns i :: (t, b1)
i = SignalBase t b1
st 
  where st :: SignalBase t b1
st     = (t, b1) -> SignalBase t b1
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t, b1)
i SignalBase t b1 -> SignalBase t b1 -> SignalBase t b1
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&>- ([b1] -> [b1]) -> SignalBase t b1 -> SignalBase t b1
forall t a1 b1.
(Ord t, Num t) =>
([a1] -> [b1]) -> SignalBase t a1 -> SignalBase t b1
comb11 [b1] -> [b1]
ns SignalBase t b1
st 
generate2 :: ([b1] -> [b2] -> ([b1], [b2]))
-> ((t, b1), (t, b2)) -> (SignalBase t b1, SignalBase t b2)
generate2 ns :: [b1] -> [b2] -> ([b1], [b2])
ns (i1 :: (t, b1)
i1,i2 :: (t, b2)
i2)
  = let (ns1 :: SignalBase t b1
ns1,ns2 :: SignalBase t b2
ns2) = ([b1] -> [b2] -> ([b1], [b2]))
-> SignalBase t b1
-> SignalBase t b2
-> (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 [b1] -> [b2] -> ([b1], [b2])
ns SignalBase t b1
st1 SignalBase t b2
st2
        (st1 :: SignalBase t b1
st1,st2 :: SignalBase t b2
st2) = ((t, b1) -> SignalBase t b1
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t, b1)
i1 SignalBase t b1 -> SignalBase t b1 -> SignalBase t b1
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&>- SignalBase t b1
ns1, (t, b2) -> SignalBase t b2
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t, b2)
i2 SignalBase t b2 -> SignalBase t b2 -> SignalBase t b2
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&>- SignalBase t b2
ns2)
    in  (SignalBase t b1
st1,SignalBase t b2
st2)
generate3 :: ([b1] -> [b2] -> [b3] -> ([b1], [b2], [b3]))
-> ((t, b1), (t, b2), (t, b3))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
generate3 ns :: [b1] -> [b2] -> [b3] -> ([b1], [b2], [b3])
ns (i1 :: (t, b1)
i1,i2 :: (t, b2)
i2,i3 :: (t, b3)
i3)
  = let (ns1 :: SignalBase t b1
ns1,ns2 :: SignalBase t b2
ns2,ns3 :: SignalBase t b3
ns3) = ([b1] -> [b2] -> [b3] -> ([b1], [b2], [b3]))
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> (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 [b1] -> [b2] -> [b3] -> ([b1], [b2], [b3])
ns SignalBase t b1
st1 SignalBase t b2
st2 SignalBase t b3
st3
        (st1 :: SignalBase t b1
st1,st2 :: SignalBase t b2
st2,st3 :: SignalBase t b3
st3) = ((t, b1) -> SignalBase t b1
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t, b1)
i1 SignalBase t b1 -> SignalBase t b1 -> SignalBase t b1
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&>- SignalBase t b1
ns1, (t, b2) -> SignalBase t b2
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t, b2)
i2 SignalBase t b2 -> SignalBase t b2 -> SignalBase t b2
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&>- SignalBase t b2
ns2, (t, b3) -> SignalBase t b3
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t, b3)
i3 SignalBase t b3 -> SignalBase t b3 -> SignalBase t b3
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&>- SignalBase t b3
ns3)
    in  (SignalBase t b1
st1,SignalBase t b2
st2,SignalBase t b3
st3)
generate4 :: ([a1] -> [a2] -> [a3] -> [a4] -> ([a1], [a2], [a3], [a4]))
-> ((t, a1), (t, a2), (t, a3), (t, a4))
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
generate4 ns :: [a1] -> [a2] -> [a3] -> [a4] -> ([a1], [a2], [a3], [a4])
ns (i1 :: (t, a1)
i1,i2 :: (t, a2)
i2,i3 :: (t, a3)
i3,i4 :: (t, a4)
i4)
  = let (ns1 :: SignalBase t a1
ns1,ns2 :: SignalBase t a2
ns2,ns3 :: SignalBase t a3
ns3,ns4 :: SignalBase t a4
ns4) = ([a1] -> [a2] -> [a3] -> [a4] -> ([a1], [a2], [a3], [a4]))
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
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] -> ([a1], [a2], [a3], [a4])
ns SignalBase t a1
st1 SignalBase t a2
st2 SignalBase t a3
st3 SignalBase t a4
st4
        (st1 :: SignalBase t a1
st1,st2 :: SignalBase t a2
st2,st3 :: SignalBase t a3
st3,st4 :: SignalBase t a4
st4) = ((t, a1) -> SignalBase t a1
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t, a1)
i1 SignalBase t a1 -> SignalBase t a1 -> SignalBase t a1
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&>- SignalBase t a1
ns1, (t, a2) -> SignalBase t a2
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t, a2)
i2 SignalBase t a2 -> SignalBase t a2 -> SignalBase t a2
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&>- SignalBase t a2
ns2,
                             (t, a3) -> SignalBase t a3
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t, a3)
i3 SignalBase t a3 -> SignalBase t a3 -> SignalBase t a3
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&>- SignalBase t a3
ns3, (t, a4) -> SignalBase t a4
forall t a. (Num t, Ord t) => (t, a) -> SignalBase t a
unit (t, a4)
i4 SignalBase t a4 -> SignalBase t a4 -> SignalBase t a4
forall (e :: * -> *) a.
MoC e =>
Stream (e a) -> Stream (e a) -> Stream (e a)
-&>- SignalBase t a4
ns4)
    in  (SignalBase t a1
st1,SignalBase t a2
st2,SignalBase t a3
st3,SignalBase t a4
st4)

------- STATED -------

b4s1 :: (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 :: SignalBase t a -> SignalBase t [a]
b4s1 = ([a] -> [[a]]) -> SignalBase t a -> SignalBase t [a]
forall t a1 b1.
(Ord t, Num t) =>
([a1] -> [b1]) -> SignalBase t a1 -> SignalBase t b1
comb11 ([a] -> [[a]] -> [[a]]
forall a. a -> [a] -> [a]
:[])
b4s2 :: SignalBase t a
-> SignalBase t a -> (SignalBase t [a], SignalBase t [a])
b4s2 s1 :: SignalBase t a
s1 s2 :: SignalBase t a
s2 = ([a], [a])
-> SignalBase t [a]
-> SignalBase t [a]
-> (SignalBase t [a], SignalBase t [a])
forall t b1 b2.
(Num t, Ord t) =>
(b1, b2)
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2)
syncAndFill2 ([],[]) (SignalBase t a -> SignalBase t [a]
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a
s1) (SignalBase t a -> SignalBase t [a]
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a
s2)
b4s3 :: SignalBase t a
-> SignalBase t a
-> SignalBase t a
-> (SignalBase t [a], SignalBase t [a], SignalBase t [a])
b4s3 s1 :: SignalBase t a
s1 s2 :: SignalBase t a
s2 s3 :: SignalBase t a
s3 = ([a], [a], [a])
-> SignalBase t [a]
-> SignalBase t [a]
-> SignalBase t [a]
-> (SignalBase t [a], SignalBase t [a], SignalBase t [a])
forall t a b c.
(Num t, Ord t) =>
(a, b, c)
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (Stream (RE t a), Stream (RE t b), Stream (RE t c))
syncAndFill3 ([],[],[]) (SignalBase t a -> SignalBase t [a]
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a
s1) (SignalBase t a -> SignalBase t [a]
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a
s2) (SignalBase t a -> SignalBase t [a]
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a
s3)

stated11 :: (Num t, Ord t)
         =>  (b1 -> [a1] -> b1)
         -> b1
         -> SignalBase t a1
         -> SignalBase t b1 
stated12 :: (Num t, Ord t)
         =>  (b1 -> b2 -> [a1] -> (b1, b2))
         -> (b1, b2)
         -> SignalBase t a1
         -> (SignalBase t b1, SignalBase t b2) 
stated13 :: (Num t, Ord t)
         =>  (b1 -> b2 -> b3 -> [a1] -> (b1, b2, b3))
         -> (b1, b2, b3)
         -> SignalBase t a1
         -> (SignalBase t b1, SignalBase t b2, SignalBase t b3) 
stated21 :: (Num t, Ord t)
         =>  (b1 -> [a1] -> [a2] -> b1)
         -> b1
         -> SignalBase t a1 -> SignalBase t a2
         -> SignalBase t b1 
-- | @state@ is a state machine without an output decoder, which exports the current
-- state. It reacts "instantaneously" with every triggering event, and has no
-- oscillation behavior. Internally it embeds a clocked SY process (see
-- 'ForSyDe.Atom.MoC.SY.Clocked.stated22').
--
-- Constructors: @stated[1-3][1-3]@.
--
-- >>> let s = readSignal "{1@1, 2@2, 3@6, 4@8, 5@9}" :: Signal Int
-- >>> stated11 (\s [a] -> s + a) 1 s
-- {1@1s,2@2s,4@6s,7@8s,11@9s}
--
-- <<fig/moc-re-pattern-state.png>>
stated22 :: (Num t, Ord t)
         =>  (b1 -> b2 -> [a1] -> [a2] -> (b1, b2))
         -- ^ next state function
         -> (b1, b2)
         -- ^ initial state values
         -> SignalBase t a1
         -- ^ first input signal
         -> SignalBase t a2
         -- ^ second input signal
         -> (SignalBase t b1, SignalBase t b2) -- ^ output signals
stated23 :: (Num t, Ord t)
         =>  (b1 -> b2 -> b3 -> [a1] -> [a2] -> (b1, b2, b3))
         -> (b1, b2, b3)
         -> SignalBase t a1 -> SignalBase t a2
         -> (SignalBase t b1, SignalBase t b2, SignalBase t b3) 
stated31 :: (Num t, Ord t)
         =>  (b1 -> [a1] -> [a2] -> [a3] -> b1)
         -> b1
         -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3
         -> SignalBase t b1 
stated32 :: (Num t, Ord t)
         =>  (b1 -> b2 -> [a1] -> [a2] -> [a3] -> (b1, b2))
         -> (b1, b2)
         -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3
         -> (SignalBase t b1, SignalBase t b2) 
stated33 :: (Num t, Ord t)
         =>  (b1 -> b2 -> b3 -> [a1] -> [a2] -> [a3] -> (b1, b2, b3))
         -> (b1, b2, b3)
         -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3
         -> (SignalBase t b1, SignalBase t b2, SignalBase t b3) 

stated11 :: (b1 -> [a1] -> b1) -> b1 -> SignalBase t a1 -> SignalBase t b1
stated11 ns :: b1 -> [a1] -> b1
ns i :: b1
i s1 :: SignalBase t a1
s1       = (Signal [a1] -> Signal b1) -> Stream (RE t [a1]) -> SignalBase t b1
forall t a a.
(Num t, Ord t) =>
(Signal a -> Signal a) -> Stream (RE t a) -> SignalBase t a
embedSY11 ((b1 -> [a1] -> b1) -> b1 -> Signal [a1] -> Signal b1
forall b1 a1. (b1 -> a1 -> b1) -> b1 -> Signal a1 -> Signal b1
SYC.stated11 b1 -> [a1] -> b1
ns b1
i) (SignalBase t a1 -> Stream (RE t [a1])
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a1
s1)
stated21 :: (b1 -> [a1] -> [a2] -> b1)
-> b1 -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
stated21 ns :: b1 -> [a1] -> [a2] -> b1
ns i :: b1
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = (Signal [a1] -> Signal [a2] -> Signal b1)
-> Stream (RE t [a1]) -> Stream (RE t [a2]) -> SignalBase t b1
forall t a b a.
(Num t, Ord t) =>
(Signal a -> Signal b -> Signal a)
-> Stream (RE t a) -> Stream (RE t b) -> SignalBase t a
embedSY21 ((b1 -> [a1] -> [a2] -> b1)
-> b1 -> Signal [a1] -> Signal [a2] -> Signal b1
forall b1 a1 a2.
(b1 -> a1 -> a2 -> b1) -> b1 -> Signal a1 -> Signal a2 -> Signal b1
SYC.stated21 b1 -> [a1] -> [a2] -> b1
ns b1
i) (Stream (RE t [a1]) -> Stream (RE t [a2]) -> SignalBase t b1)
-> (Stream (RE t [a1]), Stream (RE t [a2])) -> SignalBase t b1
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
>< SignalBase t a1
-> SignalBase t a2 -> (Stream (RE t [a1]), Stream (RE t [a2]))
forall t a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a -> (SignalBase t [a], SignalBase t [a])
b4s2 SignalBase t a1
s1 SignalBase t a2
s2
stated31 :: (b1 -> [a1] -> [a2] -> [a3] -> b1)
-> b1
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
stated31 ns :: b1 -> [a1] -> [a2] -> [a3] -> b1
ns i :: b1
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = (Signal [a1] -> Signal [a2] -> Signal [a3] -> Signal b1)
-> Stream (RE t [a1])
-> Stream (RE t [a2])
-> Stream (RE t [a3])
-> SignalBase t b1
forall t a b c a.
(Num t, Ord t) =>
(Signal a -> Signal b -> Signal c -> Signal a)
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> SignalBase t a
embedSY31 ((b1 -> [a1] -> [a2] -> [a3] -> b1)
-> b1 -> Signal [a1] -> Signal [a2] -> Signal [a3] -> Signal b1
forall b1 a1 a2 a3.
(b1 -> a1 -> a2 -> a3 -> b1)
-> b1 -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
SYC.stated31 b1 -> [a1] -> [a2] -> [a3] -> b1
ns b1
i) (Stream (RE t [a1])
 -> Stream (RE t [a2]) -> Stream (RE t [a3]) -> SignalBase t b1)
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
-> SignalBase t b1
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
><< SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
forall t a a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a
-> SignalBase t a
-> (SignalBase t [a], SignalBase t [a], SignalBase t [a])
b4s3 SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3
stated12 :: (b1 -> b2 -> [a1] -> (b1, b2))
-> (b1, b2)
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2)
stated12 ns :: b1 -> b2 -> [a1] -> (b1, b2)
ns i :: (b1, b2)
i s1 :: SignalBase t a1
s1       = (Signal [a1] -> (Signal b1, Signal b2))
-> Stream (RE t [a1]) -> (SignalBase t b1, SignalBase t b2)
forall t a a b.
(Num t, Ord t) =>
(Signal a -> (Signal a, Signal b))
-> Stream (RE t a) -> (SignalBase t a, SignalBase t b)
embedSY12 ((b1 -> b2 -> [a1] -> (b1, b2))
-> (b1, b2) -> Signal [a1] -> (Signal b1, Signal b2)
forall b1 b2 a1.
(b1 -> b2 -> a1 -> (b1, b2))
-> (b1, b2) -> Signal a1 -> (Signal b1, Signal b2)
SYC.stated12 b1 -> b2 -> [a1] -> (b1, b2)
ns (b1, b2)
i) (SignalBase t a1 -> Stream (RE t [a1])
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a1
s1)
stated22 :: (b1 -> b2 -> [a1] -> [a2] -> (b1, b2))
-> (b1, b2)
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
stated22 ns :: b1 -> b2 -> [a1] -> [a2] -> (b1, b2)
ns i :: (b1, b2)
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = (Signal [a1] -> Signal [a2] -> (Signal b1, Signal b2))
-> SignalBase t [a1]
-> SignalBase t [a2]
-> (SignalBase t b1, SignalBase t b2)
forall t a1 a2 b1 b2.
(Num t, Ord t) =>
(Signal a1 -> Signal a2 -> (Signal b1, Signal b2))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
embedSY22 ((b1 -> b2 -> [a1] -> [a2] -> (b1, b2))
-> (b1, b2) -> Signal [a1] -> Signal [a2] -> (Signal b1, Signal b2)
forall b1 b2 a1 a2.
(b1 -> b2 -> a1 -> a2 -> (b1, b2))
-> (b1, b2) -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
SYC.stated22 b1 -> b2 -> [a1] -> [a2] -> (b1, b2)
ns (b1, b2)
i) (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
>< SignalBase t a1
-> SignalBase t a2 -> (SignalBase t [a1], SignalBase t [a2])
forall t a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a -> (SignalBase t [a], SignalBase t [a])
b4s2 SignalBase t a1
s1 SignalBase t a2
s2
stated32 :: (b1 -> b2 -> [a1] -> [a2] -> [a3] -> (b1, b2))
-> (b1, b2)
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2)
stated32 ns :: b1 -> b2 -> [a1] -> [a2] -> [a3] -> (b1, b2)
ns i :: (b1, b2)
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = (Signal [a1]
 -> Signal [a2] -> Signal [a3] -> (Signal b1, Signal b2))
-> Stream (RE t [a1])
-> Stream (RE t [a2])
-> Stream (RE t [a3])
-> (SignalBase t b1, SignalBase t b2)
forall t a b c a b.
(Num t, Ord t) =>
(Signal a -> Signal b -> Signal c -> (Signal a, Signal b))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b)
embedSY32 ((b1 -> b2 -> [a1] -> [a2] -> [a3] -> (b1, b2))
-> (b1, b2)
-> Signal [a1]
-> Signal [a2]
-> Signal [a3]
-> (Signal b1, Signal b2)
forall b1 b2 a1 a2 a3.
(b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2))
-> (b1, b2)
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2)
SYC.stated32 b1 -> b2 -> [a1] -> [a2] -> [a3] -> (b1, b2)
ns (b1, b2)
i) (Stream (RE t [a1])
 -> Stream (RE t [a2])
 -> Stream (RE t [a3])
 -> (SignalBase t b1, SignalBase t b2))
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
-> (SignalBase t b1, SignalBase t b2)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
><< SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
forall t a a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a
-> SignalBase t a
-> (SignalBase t [a], SignalBase t [a], SignalBase t [a])
b4s3 SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3
stated13 :: (b1 -> b2 -> b3 -> [a1] -> (b1, b2, b3))
-> (b1, b2, b3)
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
stated13 ns :: b1 -> b2 -> b3 -> [a1] -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: SignalBase t a1
s1       = (Signal [a1] -> (Signal b1, Signal b2, Signal b3))
-> Stream (RE t [a1])
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a a b c.
(Num t, Ord t) =>
(Signal a -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY13 ((b1 -> b2 -> b3 -> [a1] -> (b1, b2, b3))
-> (b1, b2, b3) -> Signal [a1] -> (Signal b1, Signal b2, Signal b3)
forall b1 b2 b3 a1.
(b1 -> b2 -> b3 -> a1 -> (b1, b2, b3))
-> (b1, b2, b3) -> Signal a1 -> (Signal b1, Signal b2, Signal b3)
SYC.stated13 b1 -> b2 -> b3 -> [a1] -> (b1, b2, b3)
ns (b1, b2, b3)
i) (SignalBase t a1 -> Stream (RE t [a1])
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a1
s1)
stated23 :: (b1 -> b2 -> b3 -> [a1] -> [a2] -> (b1, b2, b3))
-> (b1, b2, b3)
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
stated23 ns :: b1 -> b2 -> b3 -> [a1] -> [a2] -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = (Signal [a1] -> Signal [a2] -> (Signal b1, Signal b2, Signal b3))
-> Stream (RE t [a1])
-> Stream (RE t [a2])
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a b a b c.
(Num t, Ord t) =>
(Signal a -> Signal b -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY23 ((b1 -> b2 -> b3 -> [a1] -> [a2] -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal [a1]
-> Signal [a2]
-> (Signal b1, Signal b2, Signal b3)
forall b1 b2 b3 a1 a2.
(b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
SYC.stated23 b1 -> b2 -> b3 -> [a1] -> [a2] -> (b1, b2, b3)
ns (b1, b2, b3)
i) (Stream (RE t [a1])
 -> Stream (RE t [a2])
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3))
-> (Stream (RE t [a1]), Stream (RE t [a2]))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
>< SignalBase t a1
-> SignalBase t a2 -> (Stream (RE t [a1]), Stream (RE t [a2]))
forall t a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a -> (SignalBase t [a], SignalBase t [a])
b4s2 SignalBase t a1
s1 SignalBase t a2
s2
stated33 :: (b1 -> b2 -> b3 -> [a1] -> [a2] -> [a3] -> (b1, b2, b3))
-> (b1, b2, b3)
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
stated33 ns :: b1 -> b2 -> b3 -> [a1] -> [a2] -> [a3] -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = (Signal [a1]
 -> Signal [a2] -> Signal [a3] -> (Signal b1, Signal b2, Signal b3))
-> Stream (RE t [a1])
-> Stream (RE t [a2])
-> Stream (RE t [a3])
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a b c a b c.
(Num t, Ord t) =>
(Signal a
 -> Signal b -> Signal c -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY33 ((b1 -> b2 -> b3 -> [a1] -> [a2] -> [a3] -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal [a1]
-> Signal [a2]
-> Signal [a3]
-> (Signal b1, Signal b2, Signal b3)
forall b1 b2 b3 a1 a2 a3.
(b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
SYC.stated33 b1 -> b2 -> b3 -> [a1] -> [a2] -> [a3] -> (b1, b2, b3)
ns (b1, b2, b3)
i) (Stream (RE t [a1])
 -> Stream (RE t [a2])
 -> Stream (RE t [a3])
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3))
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
><< SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
forall t a a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a
-> SignalBase t a
-> (SignalBase t [a], SignalBase t [a], SignalBase t [a])
b4s3 SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3

------- STATE -------


state11 :: (Num t, Ord t)
         =>  (b1 -> [a1] -> b1)
         -> b1
         -> SignalBase t a1
         -> SignalBase t b1 
state12 :: (Num t, Ord t)
         =>  (b1 -> b2 -> [a1] -> (b1, b2))
         -> (b1, b2)
         -> SignalBase t a1
         -> (SignalBase t b1, SignalBase t b2) 
state13 :: (Num t, Ord t)
         =>  (b1 -> b2 -> b3 -> [a1] -> (b1, b2, b3))
         -> (b1, b2, b3)
         -> SignalBase t a1
         -> (SignalBase t b1, SignalBase t b2, SignalBase t b3) 
state21 :: (Num t, Ord t)
         =>  (b1 -> [a1] -> [a2] -> b1)
         -> b1
         -> SignalBase t a1 -> SignalBase t a2
         -> SignalBase t b1 
-- | @state@ is a state machine without an output decoder, which exports the next
-- state. It reacts "instantaneously" with every triggering event, and has no
-- oscillation behavior. Internally it embeds a clocked SY process (see
-- 'ForSyDe.Atom.MoC.SY.Clocked.state22').
--
-- Constructors: @state[1-3][1-3]@.
--
-- >>> let s = readSignal "{1@1, 2@2, 3@6, 4@8, 5@9}" :: Signal Int  
-- >>> state11 (\s [a] -> s + a) 1 s
-- {2@1s,4@2s,7@6s,11@8s,16@9s}
--
-- <<fig/moc-re-pattern-state.png>>
state22 :: (Num t, Ord t)
         =>  (b1 -> b2 -> [a1] -> [a2] -> (b1, b2))
         -- ^ next state function
         -> (b1, b2)
         -- ^ initial state values
         -> SignalBase t a1
         -- ^ first input signal
         -> SignalBase t a2
         -- ^ second input signal
         -> (SignalBase t b1, SignalBase t b2) -- ^ output signals
state23 :: (Num t, Ord t)
         =>  (b1 -> b2 -> b3 -> [a1] -> [a2] -> (b1, b2, b3))
         -> (b1, b2, b3)
         -> SignalBase t a1 -> SignalBase t a2
         -> (SignalBase t b1, SignalBase t b2, SignalBase t b3) 
state31 :: (Num t, Ord t)
         =>  (b1 -> [a1] -> [a2] -> [a3] -> b1)
         -> b1
         -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3
         -> SignalBase t b1 
state32 :: (Num t, Ord t)
         =>  (b1 -> b2 -> [a1] -> [a2] -> [a3] -> (b1, b2))
         -> (b1, b2)
         -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3
         -> (SignalBase t b1, SignalBase t b2) 
state33 :: (Num t, Ord t)
         =>  (b1 -> b2 -> b3 -> [a1] -> [a2] -> [a3] -> (b1, b2, b3))
         -> (b1, b2, b3)
         -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3
         -> (SignalBase t b1, SignalBase t b2, SignalBase t b3) 

state11 :: (b1 -> [a1] -> b1) -> b1 -> SignalBase t a1 -> SignalBase t b1
state11 ns :: b1 -> [a1] -> b1
ns i :: b1
i s1 :: SignalBase t a1
s1       = (Signal [a1] -> Signal b1) -> Stream (RE t [a1]) -> SignalBase t b1
forall t a a.
(Num t, Ord t) =>
(Signal a -> Signal a) -> Stream (RE t a) -> SignalBase t a
embedSY11 ((b1 -> [a1] -> b1) -> b1 -> Signal [a1] -> Signal b1
forall b1 a1. (b1 -> a1 -> b1) -> b1 -> Signal a1 -> Signal b1
SYC.state11 b1 -> [a1] -> b1
ns b1
i) (SignalBase t a1 -> Stream (RE t [a1])
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a1
s1)
state21 :: (b1 -> [a1] -> [a2] -> b1)
-> b1 -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
state21 ns :: b1 -> [a1] -> [a2] -> b1
ns i :: b1
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = (Signal [a1] -> Signal [a2] -> Signal b1)
-> Stream (RE t [a1]) -> Stream (RE t [a2]) -> SignalBase t b1
forall t a b a.
(Num t, Ord t) =>
(Signal a -> Signal b -> Signal a)
-> Stream (RE t a) -> Stream (RE t b) -> SignalBase t a
embedSY21 ((b1 -> [a1] -> [a2] -> b1)
-> b1 -> Signal [a1] -> Signal [a2] -> Signal b1
forall b1 a1 a2.
(b1 -> a1 -> a2 -> b1) -> b1 -> Signal a1 -> Signal a2 -> Signal b1
SYC.state21 b1 -> [a1] -> [a2] -> b1
ns b1
i) (Stream (RE t [a1]) -> Stream (RE t [a2]) -> SignalBase t b1)
-> (Stream (RE t [a1]), Stream (RE t [a2])) -> SignalBase t b1
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
>< SignalBase t a1
-> SignalBase t a2 -> (Stream (RE t [a1]), Stream (RE t [a2]))
forall t a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a -> (SignalBase t [a], SignalBase t [a])
b4s2 SignalBase t a1
s1 SignalBase t a2
s2
state31 :: (b1 -> [a1] -> [a2] -> [a3] -> b1)
-> b1
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
state31 ns :: b1 -> [a1] -> [a2] -> [a3] -> b1
ns i :: b1
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = (Signal [a1] -> Signal [a2] -> Signal [a3] -> Signal b1)
-> Stream (RE t [a1])
-> Stream (RE t [a2])
-> Stream (RE t [a3])
-> SignalBase t b1
forall t a b c a.
(Num t, Ord t) =>
(Signal a -> Signal b -> Signal c -> Signal a)
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> SignalBase t a
embedSY31 ((b1 -> [a1] -> [a2] -> [a3] -> b1)
-> b1 -> Signal [a1] -> Signal [a2] -> Signal [a3] -> Signal b1
forall b1 a1 a2 a3.
(b1 -> a1 -> a2 -> a3 -> b1)
-> b1 -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
SYC.state31 b1 -> [a1] -> [a2] -> [a3] -> b1
ns b1
i) (Stream (RE t [a1])
 -> Stream (RE t [a2]) -> Stream (RE t [a3]) -> SignalBase t b1)
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
-> SignalBase t b1
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
><< SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
forall t a a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a
-> SignalBase t a
-> (SignalBase t [a], SignalBase t [a], SignalBase t [a])
b4s3 SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3
state12 :: (b1 -> b2 -> [a1] -> (b1, b2))
-> (b1, b2)
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2)
state12 ns :: b1 -> b2 -> [a1] -> (b1, b2)
ns i :: (b1, b2)
i s1 :: SignalBase t a1
s1       = (Signal [a1] -> (Signal b1, Signal b2))
-> Stream (RE t [a1]) -> (SignalBase t b1, SignalBase t b2)
forall t a a b.
(Num t, Ord t) =>
(Signal a -> (Signal a, Signal b))
-> Stream (RE t a) -> (SignalBase t a, SignalBase t b)
embedSY12 ((b1 -> b2 -> [a1] -> (b1, b2))
-> (b1, b2) -> Signal [a1] -> (Signal b1, Signal b2)
forall b1 b2 a1.
(b1 -> b2 -> a1 -> (b1, b2))
-> (b1, b2) -> Signal a1 -> (Signal b1, Signal b2)
SYC.state12 b1 -> b2 -> [a1] -> (b1, b2)
ns (b1, b2)
i) (SignalBase t a1 -> Stream (RE t [a1])
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a1
s1)
state22 :: (b1 -> b2 -> [a1] -> [a2] -> (b1, b2))
-> (b1, b2)
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
state22 ns :: b1 -> b2 -> [a1] -> [a2] -> (b1, b2)
ns i :: (b1, b2)
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = (Signal [a1] -> Signal [a2] -> (Signal b1, Signal b2))
-> SignalBase t [a1]
-> SignalBase t [a2]
-> (SignalBase t b1, SignalBase t b2)
forall t a1 a2 b1 b2.
(Num t, Ord t) =>
(Signal a1 -> Signal a2 -> (Signal b1, Signal b2))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
embedSY22 ((b1 -> b2 -> [a1] -> [a2] -> (b1, b2))
-> (b1, b2) -> Signal [a1] -> Signal [a2] -> (Signal b1, Signal b2)
forall b1 b2 a1 a2.
(b1 -> b2 -> a1 -> a2 -> (b1, b2))
-> (b1, b2) -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
SYC.state22 b1 -> b2 -> [a1] -> [a2] -> (b1, b2)
ns (b1, b2)
i) (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
>< SignalBase t a1
-> SignalBase t a2 -> (SignalBase t [a1], SignalBase t [a2])
forall t a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a -> (SignalBase t [a], SignalBase t [a])
b4s2 SignalBase t a1
s1 SignalBase t a2
s2
state32 :: (b1 -> b2 -> [a1] -> [a2] -> [a3] -> (b1, b2))
-> (b1, b2)
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2)
state32 ns :: b1 -> b2 -> [a1] -> [a2] -> [a3] -> (b1, b2)
ns i :: (b1, b2)
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = (Signal [a1]
 -> Signal [a2] -> Signal [a3] -> (Signal b1, Signal b2))
-> Stream (RE t [a1])
-> Stream (RE t [a2])
-> Stream (RE t [a3])
-> (SignalBase t b1, SignalBase t b2)
forall t a b c a b.
(Num t, Ord t) =>
(Signal a -> Signal b -> Signal c -> (Signal a, Signal b))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b)
embedSY32 ((b1 -> b2 -> [a1] -> [a2] -> [a3] -> (b1, b2))
-> (b1, b2)
-> Signal [a1]
-> Signal [a2]
-> Signal [a3]
-> (Signal b1, Signal b2)
forall b1 b2 a1 a2 a3.
(b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2))
-> (b1, b2)
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2)
SYC.state32 b1 -> b2 -> [a1] -> [a2] -> [a3] -> (b1, b2)
ns (b1, b2)
i) (Stream (RE t [a1])
 -> Stream (RE t [a2])
 -> Stream (RE t [a3])
 -> (SignalBase t b1, SignalBase t b2))
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
-> (SignalBase t b1, SignalBase t b2)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
><< SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
forall t a a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a
-> SignalBase t a
-> (SignalBase t [a], SignalBase t [a], SignalBase t [a])
b4s3 SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3
state13 :: (b1 -> b2 -> b3 -> [a1] -> (b1, b2, b3))
-> (b1, b2, b3)
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
state13 ns :: b1 -> b2 -> b3 -> [a1] -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: SignalBase t a1
s1       = (Signal [a1] -> (Signal b1, Signal b2, Signal b3))
-> Stream (RE t [a1])
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a a b c.
(Num t, Ord t) =>
(Signal a -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY13 ((b1 -> b2 -> b3 -> [a1] -> (b1, b2, b3))
-> (b1, b2, b3) -> Signal [a1] -> (Signal b1, Signal b2, Signal b3)
forall b1 b2 b3 a1.
(b1 -> b2 -> b3 -> a1 -> (b1, b2, b3))
-> (b1, b2, b3) -> Signal a1 -> (Signal b1, Signal b2, Signal b3)
SYC.state13 b1 -> b2 -> b3 -> [a1] -> (b1, b2, b3)
ns (b1, b2, b3)
i) (SignalBase t a1 -> Stream (RE t [a1])
forall t a. (Num t, Ord t) => SignalBase t a -> SignalBase t [a]
b4s1 SignalBase t a1
s1)
state23 :: (b1 -> b2 -> b3 -> [a1] -> [a2] -> (b1, b2, b3))
-> (b1, b2, b3)
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
state23 ns :: b1 -> b2 -> b3 -> [a1] -> [a2] -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = (Signal [a1] -> Signal [a2] -> (Signal b1, Signal b2, Signal b3))
-> Stream (RE t [a1])
-> Stream (RE t [a2])
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a b a b c.
(Num t, Ord t) =>
(Signal a -> Signal b -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY23 ((b1 -> b2 -> b3 -> [a1] -> [a2] -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal [a1]
-> Signal [a2]
-> (Signal b1, Signal b2, Signal b3)
forall b1 b2 b3 a1 a2.
(b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
SYC.state23 b1 -> b2 -> b3 -> [a1] -> [a2] -> (b1, b2, b3)
ns (b1, b2, b3)
i) (Stream (RE t [a1])
 -> Stream (RE t [a2])
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3))
-> (Stream (RE t [a1]), Stream (RE t [a2]))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
>< SignalBase t a1
-> SignalBase t a2 -> (Stream (RE t [a1]), Stream (RE t [a2]))
forall t a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a -> (SignalBase t [a], SignalBase t [a])
b4s2 SignalBase t a1
s1 SignalBase t a2
s2
state33 :: (b1 -> b2 -> b3 -> [a1] -> [a2] -> [a3] -> (b1, b2, b3))
-> (b1, b2, b3)
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
state33 ns :: b1 -> b2 -> b3 -> [a1] -> [a2] -> [a3] -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = (Signal [a1]
 -> Signal [a2] -> Signal [a3] -> (Signal b1, Signal b2, Signal b3))
-> Stream (RE t [a1])
-> Stream (RE t [a2])
-> Stream (RE t [a3])
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a b c a b c.
(Num t, Ord t) =>
(Signal a
 -> Signal b -> Signal c -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY33 ((b1 -> b2 -> b3 -> [a1] -> [a2] -> [a3] -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal [a1]
-> Signal [a2]
-> Signal [a3]
-> (Signal b1, Signal b2, Signal b3)
forall b1 b2 b3 a1 a2 a3.
(b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
SYC.state33 b1 -> b2 -> b3 -> [a1] -> [a2] -> [a3] -> (b1, b2, b3)
ns (b1, b2, b3)
i) (Stream (RE t [a1])
 -> Stream (RE t [a2])
 -> Stream (RE t [a3])
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3))
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
><< SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (Stream (RE t [a1]), Stream (RE t [a2]), Stream (RE t [a3]))
forall t a a a.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t a
-> SignalBase t a
-> (SignalBase t [a], SignalBase t [a], SignalBase t [a])
b4s3 SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3

------- MOORE -------

-- | @moore@ processes model Moore state machines. It reacts "instantaneously" with
-- every triggering event, and has no oscillation behavior. Internally it embeds a
-- clocked SY process (see 'ForSyDe.Atom.MoC.SY.Clocked.moore22').
--
-- Constructors: @moore[1-3][1-3]@
--
-- >>> let { ns s [a] [b] = s+a+b; ns s [] [b] = s; ns _ _ _ = 0 }
-- >>> let od s = [s + 1]
-- >>> let s1 = readSignal "{1@1, 2@2, 3@6, 4@8, 5@9}" :: Signal Int  
-- >>> let s2 = readSignal "{1@2, 1@3, 3@6, 4@8, 5@9}" :: Signal Int
-- >>> moore21 ns od 1 s1 s2
-- {2@1s,1@2s,4@3s,4@6s,10@8s,18@9s}
--
-- <<fig/moc-re-pattern-moore.png>>          
moore22 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> st)
        -- ^ next state function
        -> (st -> ([b1], [b2]))
        -- ^ output decoder
        -> st
        -- ^ initial state: tag and value
        -> SignalBase t a1 -> SignalBase t a2 -> (SignalBase t b1, SignalBase t b2)
moore11 :: (Num t, Ord t)
        =>  (st -> [a1] -> st)
        -> (st -> [b1])
        -> st
        -> SignalBase t a1
        -> SignalBase t b1                                
moore12 :: (Num t, Ord t)
        =>  (st -> [a1] -> st)
        -> (st -> ([b1], [b2]))
        -> st
        -> SignalBase t a1
        -> (SignalBase t b1, SignalBase t b2)                          
moore13 :: (Num t, Ord t)
        =>  (st -> [a1] -> st)
        -> (st -> ([b1], [b2], [b3]))
        -> st
        -> SignalBase t a1
        -> (SignalBase t b1, SignalBase t b2, SignalBase t b3)                      
moore21 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> st)
        -> (st -> [b1])
        -> st
        -> SignalBase t a1 -> SignalBase t a2
        -> SignalBase t b1                          
moore23 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> st)
        -> (st -> ([b1], [b2], [b3]))
        -> st
        -> SignalBase t a1 -> SignalBase t a2
        -> (SignalBase t b1, SignalBase t b2, SignalBase t b3)                
moore31 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> [a3] -> st)
        -> (st -> [b1])
        -> st
        -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3
        -> SignalBase t b1                    
moore32 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> [a3] -> st)
        -> (st -> ([b1], [b2]))
        -> st
        -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3
        -> (SignalBase t b1, SignalBase t b2)              
moore33 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> [a3] -> st)
        -> (st -> ([b1], [b2], [b3]))
        -> st
        -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3
        -> (SignalBase t b1, SignalBase t b2, SignalBase t b3)          

moore11 :: (st -> [a1] -> st)
-> (st -> [b1]) -> st -> SignalBase t a1 -> SignalBase t b1
moore11 ns :: st -> [a1] -> st
ns od :: st -> [b1]
od i :: st
i s1 :: SignalBase t a1
s1       = ([st] -> [b1]) -> SignalBase t st -> SignalBase t b1
forall t a1 b1.
(Ord t, Num t) =>
([a1] -> [b1]) -> SignalBase t a1 -> SignalBase t b1
comb11 ((st -> [b1]) -> [st] -> [b1]
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [b1]
od) (SignalBase t st -> SignalBase t b1)
-> SignalBase t st -> SignalBase t b1
forall a b. (a -> b) -> a -> b
$ (st -> [a1] -> st) -> st -> SignalBase t a1 -> SignalBase t st
forall t b1 a1.
(Num t, Ord t) =>
(b1 -> [a1] -> b1) -> b1 -> SignalBase t a1 -> SignalBase t b1
stated11 st -> [a1] -> st
ns st
i SignalBase t a1
s1
moore21 :: (st -> [a1] -> [a2] -> st)
-> (st -> [b1])
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t b1
moore21 ns :: st -> [a1] -> [a2] -> st
ns od :: st -> [b1]
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = ([st] -> [b1]) -> SignalBase t st -> SignalBase t b1
forall t a1 b1.
(Ord t, Num t) =>
([a1] -> [b1]) -> SignalBase t a1 -> SignalBase t b1
comb11 ((st -> [b1]) -> [st] -> [b1]
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [b1]
od) (SignalBase t st -> SignalBase t b1)
-> SignalBase t st -> SignalBase t b1
forall a b. (a -> b) -> a -> b
$ (st -> [a1] -> [a2] -> st)
-> st -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t st
forall t b1 a1 a2.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> b1)
-> b1 -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
stated21 st -> [a1] -> [a2] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2
moore31 :: (st -> [a1] -> [a2] -> [a3] -> st)
-> (st -> [b1])
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
moore31 ns :: st -> [a1] -> [a2] -> [a3] -> st
ns od :: st -> [b1]
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = ([st] -> [b1]) -> SignalBase t st -> SignalBase t b1
forall t a1 b1.
(Ord t, Num t) =>
([a1] -> [b1]) -> SignalBase t a1 -> SignalBase t b1
comb11 ((st -> [b1]) -> [st] -> [b1]
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [b1]
od) (SignalBase t st -> SignalBase t b1)
-> SignalBase t st -> SignalBase t b1
forall a b. (a -> b) -> a -> b
$ (st -> [a1] -> [a2] -> [a3] -> st)
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t st
forall t b1 a1 a2 a3.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> [a3] -> b1)
-> b1
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
stated31 st -> [a1] -> [a2] -> [a3] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3
moore12 :: (st -> [a1] -> st)
-> (st -> ([b1], [b2]))
-> st
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2)
moore12 ns :: st -> [a1] -> st
ns od :: st -> ([b1], [b2])
od i :: st
i s1 :: SignalBase t a1
s1       = ([st] -> ([b1], [b2]))
-> SignalBase t st -> (SignalBase t b1, SignalBase t b2)
forall t a1 b1 b2.
(Num t, Ord t) =>
([a1] -> ([b1], [b2]))
-> SignalBase t a1 -> (SignalBase t b1, SignalBase t b2)
comb12 ((st -> ([b1], [b2])) -> [st] -> ([b1], [b2])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> ([b1], [b2])
od) (SignalBase t st -> (SignalBase t b1, SignalBase t b2))
-> SignalBase t st -> (SignalBase t b1, SignalBase t b2)
forall a b. (a -> b) -> a -> b
$ (st -> [a1] -> st) -> st -> SignalBase t a1 -> SignalBase t st
forall t b1 a1.
(Num t, Ord t) =>
(b1 -> [a1] -> b1) -> b1 -> SignalBase t a1 -> SignalBase t b1
stated11 st -> [a1] -> st
ns st
i SignalBase t a1
s1 
moore22 :: (st -> [a1] -> [a2] -> st)
-> (st -> ([b1], [b2]))
-> st
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
moore22 ns :: st -> [a1] -> [a2] -> st
ns od :: st -> ([b1], [b2])
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = ([st] -> ([b1], [b2]))
-> SignalBase t st -> (SignalBase t b1, SignalBase t b2)
forall t a1 b1 b2.
(Num t, Ord t) =>
([a1] -> ([b1], [b2]))
-> SignalBase t a1 -> (SignalBase t b1, SignalBase t b2)
comb12 ((st -> ([b1], [b2])) -> [st] -> ([b1], [b2])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> ([b1], [b2])
od) (SignalBase t st -> (SignalBase t b1, SignalBase t b2))
-> SignalBase t st -> (SignalBase t b1, SignalBase t b2)
forall a b. (a -> b) -> a -> b
$ (st -> [a1] -> [a2] -> st)
-> st -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t st
forall t b1 a1 a2.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> b1)
-> b1 -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
stated21 st -> [a1] -> [a2] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2
moore32 :: (st -> [a1] -> [a2] -> [a3] -> st)
-> (st -> ([b1], [b2]))
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2)
moore32 ns :: st -> [a1] -> [a2] -> [a3] -> st
ns od :: st -> ([b1], [b2])
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = ([st] -> ([b1], [b2]))
-> SignalBase t st -> (SignalBase t b1, SignalBase t b2)
forall t a1 b1 b2.
(Num t, Ord t) =>
([a1] -> ([b1], [b2]))
-> SignalBase t a1 -> (SignalBase t b1, SignalBase t b2)
comb12 ((st -> ([b1], [b2])) -> [st] -> ([b1], [b2])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> ([b1], [b2])
od) (SignalBase t st -> (SignalBase t b1, SignalBase t b2))
-> SignalBase t st -> (SignalBase t b1, SignalBase t b2)
forall a b. (a -> b) -> a -> b
$ (st -> [a1] -> [a2] -> [a3] -> st)
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t st
forall t b1 a1 a2 a3.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> [a3] -> b1)
-> b1
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
stated31 st -> [a1] -> [a2] -> [a3] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3
moore13 :: (st -> [a1] -> st)
-> (st -> ([b1], [b2], [b3]))
-> st
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
moore13 ns :: st -> [a1] -> st
ns od :: st -> ([b1], [b2], [b3])
od i :: st
i s1 :: SignalBase t a1
s1       = ([st] -> ([b1], [b2], [b3]))
-> SignalBase t st
-> (SignalBase t b1, SignalBase t b2, SignalBase t 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 ((st -> ([b1], [b2], [b3])) -> [st] -> ([b1], [b2], [b3])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> ([b1], [b2], [b3])
od) (SignalBase t st
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3))
-> SignalBase t st
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall a b. (a -> b) -> a -> b
$ (st -> [a1] -> st) -> st -> SignalBase t a1 -> SignalBase t st
forall t b1 a1.
(Num t, Ord t) =>
(b1 -> [a1] -> b1) -> b1 -> SignalBase t a1 -> SignalBase t b1
stated11 st -> [a1] -> st
ns st
i SignalBase t a1
s1
moore23 :: (st -> [a1] -> [a2] -> st)
-> (st -> ([b1], [b2], [b3]))
-> st
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
moore23 ns :: st -> [a1] -> [a2] -> st
ns od :: st -> ([b1], [b2], [b3])
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = ([st] -> ([b1], [b2], [b3]))
-> SignalBase t st
-> (SignalBase t b1, SignalBase t b2, SignalBase t 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 ((st -> ([b1], [b2], [b3])) -> [st] -> ([b1], [b2], [b3])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> ([b1], [b2], [b3])
od) (SignalBase t st
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3))
-> SignalBase t st
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall a b. (a -> b) -> a -> b
$ (st -> [a1] -> [a2] -> st)
-> st -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t st
forall t b1 a1 a2.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> b1)
-> b1 -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
stated21 st -> [a1] -> [a2] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2
moore33 :: (st -> [a1] -> [a2] -> [a3] -> st)
-> (st -> ([b1], [b2], [b3]))
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
moore33 ns :: st -> [a1] -> [a2] -> [a3] -> st
ns od :: st -> ([b1], [b2], [b3])
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = ([st] -> ([b1], [b2], [b3]))
-> SignalBase t st
-> (SignalBase t b1, SignalBase t b2, SignalBase t 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 ((st -> ([b1], [b2], [b3])) -> [st] -> ([b1], [b2], [b3])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> ([b1], [b2], [b3])
od) (SignalBase t st
 -> (SignalBase t b1, SignalBase t b2, SignalBase t b3))
-> SignalBase t st
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall a b. (a -> b) -> a -> b
$ (st -> [a1] -> [a2] -> [a3] -> st)
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t st
forall t b1 a1 a2 a3.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> [a3] -> b1)
-> b1
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
stated31 st -> [a1] -> [a2] -> [a3] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3

------- MEALY -------

-- | @mealy@ processes model Mealy state machines. It reacts "instantaneously" with
-- every triggering event, and has no oscillation behavior. Internally it embeds a
-- clocked SY process (see 'ForSyDe.Atom.MoC.SY.Clocked.mealy22').
--
-- Constructors: @mealy[1-4][1-4]@
--
-- >>> let { ns s [a] [b] = s+a+b; ns s [] [b] = s; ns _ _ _ = 0 }
-- >>> let { od s [a] [b] = [s+a-b]; od s _ _ = [s] }
-- >>> let s1 = readSignal "{1@1, 2@2, 3@6, 4@8, 5@9}" :: Signal Int  
-- >>> let s2 = readSignal "{1@2, 1@3, 3@6, 4@8, 5@9}" :: Signal Int
-- >>> mealy21 ns od 1 s1 s2
-- {1@1s,1@2s,3@3s,3@6s,9@8s,17@9s}
--
-- <<fig/moc-re-pattern-mealy.png>>
mealy22 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> st)
        -- ^ next state function
        -> (st -> [a1] -> [a2] -> ([b1], [b2]))
        -- ^ outpt decoder
        -> st
        -- ^ initial state: tag and value
        -> SignalBase t a1 -> SignalBase t a2
        -> (SignalBase t b1, SignalBase t b2)
mealy11 :: (Num t, Ord t)
        =>  (st -> [a1] -> st) 
        -> (st -> [a1] -> [b1]) 
        -> st
        -> SignalBase t a1
        -> SignalBase t b1                                
mealy12 :: (Num t, Ord t)
        =>  (st -> [a1] -> st) 
        -> (st -> [a1] -> ([b1], [b2])) 
        -> st
        -> SignalBase t a1 
        -> (SignalBase t b1, SignalBase t b2)                          
mealy13 :: (Num t, Ord t)
        =>  (st -> [a1] -> st) 
        -> (st -> [a1] -> ([b1], [b2], [b3])) 
        -> st
        -> SignalBase t a1 
        -> (SignalBase t b1, SignalBase t b2, SignalBase t b3)                      
mealy21 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> st) 
        -> (st -> [a1] -> [a2] -> [b1]) 
        -> st
        -> SignalBase t a1 -> SignalBase t a2
        -> SignalBase t b1                          
mealy23 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> st) 
        -> (st -> [a1] -> [a2] -> ([b1], [b2], [b3])) 
        -> st
        -> SignalBase t a1 -> SignalBase t a2 
        -> (SignalBase t b1, SignalBase t b2, SignalBase t b3)                
mealy31 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> [a3] -> st) 
        -> (st -> [a1] -> [a2] -> [a3] -> [b1]) 
        -> st
        -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3
        -> SignalBase t b1  
mealy32 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> [a3] -> st) 
        -> (st -> [a1] -> [a2] -> [a3] -> ([b1], [b2])) 
        -> st
        -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3 
        -> (SignalBase t b1, SignalBase t b2)              
mealy33 :: (Num t, Ord t)
        =>  (st -> [a1] -> [a2] -> [a3] -> st) 
        -> (st -> [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3])) 
        -> st
        -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t a3 
        -> (SignalBase t b1, SignalBase t b2, SignalBase t b3)          
mealy11 :: (st -> [a1] -> st)
-> (st -> [a1] -> [b1]) -> st -> SignalBase t a1 -> SignalBase t b1
mealy11 ns :: st -> [a1] -> st
ns od :: st -> [a1] -> [b1]
od i :: st
i s1 :: SignalBase t a1
s1       = ([st] -> [a1] -> [b1])
-> SignalBase t st -> SignalBase t a1 -> 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 ((st -> [a1] -> [b1]) -> [st] -> [a1] -> [b1]
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [a1] -> [b1]
od) ((st -> [a1] -> st) -> st -> SignalBase t a1 -> SignalBase t st
forall t b1 a1.
(Num t, Ord t) =>
(b1 -> [a1] -> b1) -> b1 -> SignalBase t a1 -> SignalBase t b1
stated11 st -> [a1] -> st
ns st
i SignalBase t a1
s1) SignalBase t a1
s1
mealy21 :: (st -> [a1] -> [a2] -> st)
-> (st -> [a1] -> [a2] -> [b1])
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t b1
mealy21 ns :: st -> [a1] -> [a2] -> st
ns od :: st -> [a1] -> [a2] -> [b1]
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = ([st] -> [a1] -> [a2] -> [b1])
-> SignalBase t st
-> SignalBase t a1
-> SignalBase t a2
-> 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 ((st -> [a1] -> [a2] -> [b1]) -> [st] -> [a1] -> [a2] -> [b1]
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [a1] -> [a2] -> [b1]
od) ((st -> [a1] -> [a2] -> st)
-> st -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t st
forall t b1 a1 a2.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> b1)
-> b1 -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
stated21 st -> [a1] -> [a2] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2) SignalBase t a1
s1 SignalBase t a2
s2
mealy31 :: (st -> [a1] -> [a2] -> [a3] -> st)
-> (st -> [a1] -> [a2] -> [a3] -> [b1])
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
mealy31 ns :: st -> [a1] -> [a2] -> [a3] -> st
ns od :: st -> [a1] -> [a2] -> [a3] -> [b1]
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = ([st] -> [a1] -> [a2] -> [a3] -> [b1])
-> SignalBase t st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> 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 ((st -> [a1] -> [a2] -> [a3] -> [b1])
-> [st] -> [a1] -> [a2] -> [a3] -> [b1]
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [a1] -> [a2] -> [a3] -> [b1]
od) ((st -> [a1] -> [a2] -> [a3] -> st)
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t st
forall t b1 a1 a2 a3.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> [a3] -> b1)
-> b1
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
stated31 st -> [a1] -> [a2] -> [a3] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3) SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3
mealy12 :: (st -> [a1] -> st)
-> (st -> [a1] -> ([b1], [b2]))
-> st
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2)
mealy12 ns :: st -> [a1] -> st
ns od :: st -> [a1] -> ([b1], [b2])
od i :: st
i s1 :: SignalBase t a1
s1       = ([st] -> [a1] -> ([b1], [b2]))
-> SignalBase t st
-> SignalBase t a1
-> (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 ((st -> [a1] -> ([b1], [b2])) -> [st] -> [a1] -> ([b1], [b2])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [a1] -> ([b1], [b2])
od) ((st -> [a1] -> st) -> st -> SignalBase t a1 -> SignalBase t st
forall t b1 a1.
(Num t, Ord t) =>
(b1 -> [a1] -> b1) -> b1 -> SignalBase t a1 -> SignalBase t b1
stated11 st -> [a1] -> st
ns st
i SignalBase t a1
s1) SignalBase t a1
s1
mealy22 :: (st -> [a1] -> [a2] -> st)
-> (st -> [a1] -> [a2] -> ([b1], [b2]))
-> st
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
mealy22 ns :: st -> [a1] -> [a2] -> st
ns od :: st -> [a1] -> [a2] -> ([b1], [b2])
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = ([st] -> [a1] -> [a2] -> ([b1], [b2]))
-> SignalBase t st
-> SignalBase t a1
-> SignalBase t a2
-> (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 ((st -> [a1] -> [a2] -> ([b1], [b2]))
-> [st] -> [a1] -> [a2] -> ([b1], [b2])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [a1] -> [a2] -> ([b1], [b2])
od) ((st -> [a1] -> [a2] -> st)
-> st -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t st
forall t b1 a1 a2.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> b1)
-> b1 -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
stated21 st -> [a1] -> [a2] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2) SignalBase t a1
s1 SignalBase t a2
s2
mealy32 :: (st -> [a1] -> [a2] -> [a3] -> st)
-> (st -> [a1] -> [a2] -> [a3] -> ([b1], [b2]))
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2)
mealy32 ns :: st -> [a1] -> [a2] -> [a3] -> st
ns od :: st -> [a1] -> [a2] -> [a3] -> ([b1], [b2])
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = ([st] -> [a1] -> [a2] -> [a3] -> ([b1], [b2]))
-> SignalBase t st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (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 ((st -> [a1] -> [a2] -> [a3] -> ([b1], [b2]))
-> [st] -> [a1] -> [a2] -> [a3] -> ([b1], [b2])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [a1] -> [a2] -> [a3] -> ([b1], [b2])
od) ((st -> [a1] -> [a2] -> [a3] -> st)
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t st
forall t b1 a1 a2 a3.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> [a3] -> b1)
-> b1
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
stated31 st -> [a1] -> [a2] -> [a3] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3) SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3
mealy13 :: (st -> [a1] -> st)
-> (st -> [a1] -> ([b1], [b2], [b3]))
-> st
-> SignalBase t a1
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
mealy13 ns :: st -> [a1] -> st
ns od :: st -> [a1] -> ([b1], [b2], [b3])
od i :: st
i s1 :: SignalBase t a1
s1       = ([st] -> [a1] -> ([b1], [b2], [b3]))
-> SignalBase t st
-> SignalBase t a1
-> (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 ((st -> [a1] -> ([b1], [b2], [b3]))
-> [st] -> [a1] -> ([b1], [b2], [b3])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [a1] -> ([b1], [b2], [b3])
od) ((st -> [a1] -> st) -> st -> SignalBase t a1 -> SignalBase t st
forall t b1 a1.
(Num t, Ord t) =>
(b1 -> [a1] -> b1) -> b1 -> SignalBase t a1 -> SignalBase t b1
stated11 st -> [a1] -> st
ns st
i SignalBase t a1
s1) SignalBase t a1
s1
mealy23 :: (st -> [a1] -> [a2] -> st)
-> (st -> [a1] -> [a2] -> ([b1], [b2], [b3]))
-> st
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
mealy23 ns :: st -> [a1] -> [a2] -> st
ns od :: st -> [a1] -> [a2] -> ([b1], [b2], [b3])
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2    = ([st] -> [a1] -> [a2] -> ([b1], [b2], [b3]))
-> SignalBase t st
-> SignalBase t a1
-> SignalBase t a2
-> (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 ((st -> [a1] -> [a2] -> ([b1], [b2], [b3]))
-> [st] -> [a1] -> [a2] -> ([b1], [b2], [b3])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [a1] -> [a2] -> ([b1], [b2], [b3])
od) ((st -> [a1] -> [a2] -> st)
-> st -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t st
forall t b1 a1 a2.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> b1)
-> b1 -> SignalBase t a1 -> SignalBase t a2 -> SignalBase t b1
stated21 st -> [a1] -> [a2] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2) SignalBase t a1
s1 SignalBase t a2
s2
mealy33 :: (st -> [a1] -> [a2] -> [a3] -> st)
-> (st -> [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3]))
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
mealy33 ns :: st -> [a1] -> [a2] -> [a3] -> st
ns od :: st -> [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3])
od i :: st
i s1 :: SignalBase t a1
s1 s2 :: SignalBase t a2
s2 s3 :: SignalBase t a3
s3 = ([st] -> [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3]))
-> SignalBase t st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (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 ((st -> [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3]))
-> [st] -> [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3])
forall t1 t2. (t1 -> t2) -> [t1] -> t2
li1 st -> [a1] -> [a2] -> [a3] -> ([b1], [b2], [b3])
od) ((st -> [a1] -> [a2] -> [a3] -> st)
-> st
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t st
forall t b1 a1 a2 a3.
(Num t, Ord t) =>
(b1 -> [a1] -> [a2] -> [a3] -> b1)
-> b1
-> SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t b1
stated31 st -> [a1] -> [a2] -> [a3] -> st
ns st
i SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3) SignalBase t a1
s1 SignalBase t a2
s2 SignalBase t a3
s3


----------------------------------------------------

-- | Synchronizes /n/ signals and for each absent event at a synchronization point, it
-- holds the previous non-absent one.
--
-- Constructors: @syncAndHold[2-4]@
--
-- >>> let s1 = readSignal "{1@1, 2@2, 3@6, 4@8, 5@9}" :: Signal Int
-- >>> let s2 = readSignal "{3@2, 4@4, 5@5, 6@8, 7@9}" :: Signal Int
-- >>> let (o1,o2) = syncAndHold2 (0,0) s1 s2
-- >>> o1
-- {1@1s,2@2s,2@4s,2@5s,3@6s,4@8s,5@9s}
-- >>> o2
-- {0@1s,3@2s,4@4s,5@5s,5@6s,6@8s,7@9s}
--
-- <<fig/moc-re-pattern-syncandhold.png>>
syncAndHold2 :: (Num t, Ord t)
             => (b1, b2) -- ^ initial value(s), if no previous present event exists.
             -> SignalBase t b1 -> SignalBase t b2
             -> (SignalBase t b1, SignalBase t b2) 
syncAndHold2 :: (b1, b2)
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2)
syncAndHold2 (i1 :: b1
i1,i2 :: b2
i2)
  = (Signal b1 -> Signal b2 -> (Signal b1, Signal b2))
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2)
forall t a1 a2 b1 b2.
(Num t, Ord t) =>
(Signal a1 -> Signal a2 -> (Signal b1, Signal b2))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
embedSY22 (\s1 :: Signal b1
s1 s2 :: Signal b2
s2 ->
                 (b1 -> Signal b1 -> Signal b1
forall a. a -> Signal a -> Signal a
SYC.current b1
i1 Signal b1
s1, b2 -> Signal b2 -> Signal b2
forall a. a -> Signal a -> Signal a
SYC.current b2
i2 Signal b2
s2))
syncAndHold3 :: (a, b, c)
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (Stream (RE t a), Stream (RE t b), Stream (RE t c))
syncAndHold3 (i1 :: a
i1,i2 :: b
i2,i3 :: c
i3)
  = (Signal a
 -> Signal b -> Signal c -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (Stream (RE t a), Stream (RE t b), Stream (RE t c))
forall t a b c a b c.
(Num t, Ord t) =>
(Signal a
 -> Signal b -> Signal c -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY33 (\s1 :: Signal a
s1 s2 :: Signal b
s2 s3 :: Signal c
s3 ->
                 (a -> Signal a -> Signal a
forall a. a -> Signal a -> Signal a
SYC.current a
i1 Signal a
s1, b -> Signal b -> Signal b
forall a. a -> Signal a -> Signal a
SYC.current b
i2 Signal b
s2,
                   c -> Signal c -> Signal c
forall a. a -> Signal a -> Signal a
SYC.current c
i3 Signal c
s3))
syncAndHold4 :: (a, b, c, d)
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (Stream (RE t a), Stream (RE t b), Stream (RE t c),
    Stream (RE t d))
syncAndHold4 (i1 :: a
i1,i2 :: b
i2,i3 :: c
i3,i4 :: d
i4)
  = (Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (Stream (RE t a), Stream (RE t b), Stream (RE t c),
    Stream (RE t d))
forall t a b c d a b c d.
(Num t, Ord t) =>
(Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
embedSY44 (\s1 :: Signal a
s1 s2 :: Signal b
s2 s3 :: Signal c
s3 s4 :: Signal d
s4 ->
                 (a -> Signal a -> Signal a
forall a. a -> Signal a -> Signal a
SYC.current a
i1 Signal a
s1, b -> Signal b -> Signal b
forall a. a -> Signal a -> Signal a
SYC.current b
i2 Signal b
s2,
                   c -> Signal c -> Signal c
forall a. a -> Signal a -> Signal a
SYC.current c
i3 Signal c
s3, d -> Signal d -> Signal d
forall a. a -> Signal a -> Signal a
SYC.current d
i4 Signal d
s4))
    
-- | Synchronizes /n/ signals and for each absent event at a synchronization point, it
-- replaces it with an arbitrary user-defined value.
--
-- Constructors: @syncAndFill[2-4]@
--
-- >>> let s1 = readSignal "{1@1, 2@2, 3@6, 4@8, 5@9}" :: Signal Int
-- >>> let s2 = readSignal "{3@2, 4@4, 5@5, 6@8, 7@9}" :: Signal Int
-- >>> let (o1,o2) = syncAndFill2 (0,0) s1 s2
-- >>> o1
-- {1@1s,2@2s,0@4s,0@5s,3@6s,4@8s,5@9s}
-- >>> o2
-- {0@1s,3@2s,4@4s,5@5s,0@6s,6@8s,7@9s}
--
-- <<fig/moc-re-pattern-syncandfill.png>>
syncAndFill2 :: (Num t, Ord t)
             => (b1, b2) -- ^ initial value(s), if no previous present event exists.
             -> SignalBase t b1 -> SignalBase t b2
             -> (SignalBase t b1, SignalBase t b2) 
syncAndFill2 :: (b1, b2)
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2)
syncAndFill2 (i1 :: b1
i1,i2 :: b2
i2)
  = (Signal b1 -> Signal b2 -> (Signal b1, Signal b2))
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2)
forall t a1 a2 b1 b2.
(Num t, Ord t) =>
(Signal a1 -> Signal a2 -> (Signal b1, Signal b2))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
embedSY22 (\s1 :: Signal b1
s1 s2 :: Signal b2
s2 ->
                 (b1 -> Signal b1 -> Signal b1
forall a. a -> Signal a -> Signal a
SYC.fill b1
i1 Signal b1
s1, b2 -> Signal b2 -> Signal b2
forall a. a -> Signal a -> Signal a
SYC.fill b2
i2 Signal b2
s2))
syncAndFill3 :: (a, b, c)
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (Stream (RE t a), Stream (RE t b), Stream (RE t c))
syncAndFill3 (i1 :: a
i1,i2 :: b
i2,i3 :: c
i3)
  = (Signal a
 -> Signal b -> Signal c -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (Stream (RE t a), Stream (RE t b), Stream (RE t c))
forall t a b c a b c.
(Num t, Ord t) =>
(Signal a
 -> Signal b -> Signal c -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY33 (\s1 :: Signal a
s1 s2 :: Signal b
s2 s3 :: Signal c
s3 ->
                 (a -> Signal a -> Signal a
forall a. a -> Signal a -> Signal a
SYC.fill a
i1 Signal a
s1, b -> Signal b -> Signal b
forall a. a -> Signal a -> Signal a
SYC.fill b
i2 Signal b
s2,
                   c -> Signal c -> Signal c
forall a. a -> Signal a -> Signal a
SYC.fill c
i3 Signal c
s3))
syncAndFill4 :: (a, b, c, d)
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (Stream (RE t a), Stream (RE t b), Stream (RE t c),
    Stream (RE t d))
syncAndFill4 (i1 :: a
i1,i2 :: b
i2,i3 :: c
i3,i4 :: d
i4)
  = (Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (Stream (RE t a), Stream (RE t b), Stream (RE t c),
    Stream (RE t d))
forall t a b c d a b c d.
(Num t, Ord t) =>
(Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
embedSY44 (\s1 :: Signal a
s1 s2 :: Signal b
s2 s3 :: Signal c
s3 s4 :: Signal d
s4 ->
                 (a -> Signal a -> Signal a
forall a. a -> Signal a -> Signal a
SYC.fill a
i1 Signal a
s1, b -> Signal b -> Signal b
forall a. a -> Signal a -> Signal a
SYC.fill b
i2 Signal b
s2,
                   c -> Signal c -> Signal c
forall a. a -> Signal a -> Signal a
SYC.fill c
i3 Signal c
s3, d -> Signal d -> Signal d
forall a. a -> Signal a -> Signal a
SYC.fill d
i4 Signal d
s4))

-- | @syncAndObs@\(mn\) synchronizes \(m + n\) signals where the first \(m\) are
-- /triggering/ signals and the last \(n\) /non-triggering/ (observed) signals.
--
-- Constructors: @syncAndObs11@, @syncAndObs21@, @syncAndObs31@, @syncAndObs12@, @syncAndObs22@, @syncAndObs13@.
--
-- >>> let s1 = readSignal "{1@1, 2@2, 3@6, 4@8, 5@9}" :: Signal Int
-- >>> let s2 = readSignal "{3@2, 4@4, 5@5, 6@8, 7@9}" :: Signal Int
-- >>> let (o1,o2) = syncAndObs11 0 s1 s2
-- >>> o1
-- {1@1s,2@2s,3@6s,4@8s,5@9s}
-- >>> o2
-- {0@1s,3@2s,4@4s,5@5s,5@6s,6@8s,7@9s}
--
-- <<fig/moc-re-pattern-syncandobs.png>>
syncAndObs11 :: (Num t, Ord t)
             => b2 -- ^ initial value(s), if no previous present event exists.
             -> SignalBase t b1 -> SignalBase t b2
             -> (SignalBase t b1, SignalBase t b2) 
syncAndObs21 :: (Num t, Ord t) => b3 
             -> SignalBase t b1 -> SignalBase t b2 -> SignalBase t b3
             -> (SignalBase t b1, SignalBase t b2, SignalBase t b3) 
syncAndObs31 :: (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) 
syncAndObs12 :: (Num t, Ord t) => (b2,b3) 
             -> SignalBase t b1 -> SignalBase t b2 -> SignalBase t b3
             -> (SignalBase t b1, SignalBase t b2, SignalBase t b3) 
syncAndObs22 :: (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) 
syncAndObs13 :: (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) 

syncAndObs11 :: b2
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2)
syncAndObs11 i1 :: b2
i1
  = (Signal b1 -> Signal b2 -> (Signal b1, Signal b2))
-> SignalBase t b1
-> SignalBase t b2
-> (SignalBase t b1, SignalBase t b2)
forall t a1 a2 b1 b2.
(Num t, Ord t) =>
(Signal a1 -> Signal a2 -> (Signal b1, Signal b2))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
embedSY22 (\t1 :: Signal b1
t1 o1 :: Signal b2
o1 ->
                 (Signal b1
t1, b2 -> Signal b2 -> Signal b2
forall a. a -> Signal a -> Signal a
SYC.current b2
i1 Signal b2
o1))
syncAndObs21 :: b3
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
syncAndObs21 i1 :: b3
i1
  = (Signal b1
 -> Signal b2 -> Signal b3 -> (Signal b1, Signal b2, Signal b3))
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a b c a b c.
(Num t, Ord t) =>
(Signal a
 -> Signal b -> Signal c -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY33 (\t1 :: Signal b1
t1 t2 :: Signal b2
t2 o1 :: Signal b3
o1 ->
                 (Signal b1
t1, Signal b2
t2, b3 -> Signal b3 -> Signal b3
forall a. a -> Signal a -> Signal a
SYC.current b3
i1 Signal b3
o1))
syncAndObs31 :: 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 i1 :: b4
i1
  = (Signal b1
 -> Signal b2
 -> Signal b3
 -> Signal b4
 -> (Signal b1, Signal b2, Signal b3, Signal 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 a b c d a b c d.
(Num t, Ord t) =>
(Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
embedSY44 (\t1 :: Signal b1
t1 t2 :: Signal b2
t2 t3 :: Signal b3
t3 o1 :: Signal b4
o1 ->
                 (Signal b1
t1, Signal b2
t2, Signal b3
t3, b4 -> Signal b4 -> Signal b4
forall a. a -> Signal a -> Signal a
SYC.current b4
i1 Signal b4
o1))
syncAndObs12 :: (b2, b3)
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
syncAndObs12 (i1 :: b2
i1,i2 :: b3
i2)
  = (Signal b1
 -> Signal b2 -> Signal b3 -> (Signal b1, Signal b2, Signal b3))
-> SignalBase t b1
-> SignalBase t b2
-> SignalBase t b3
-> (SignalBase t b1, SignalBase t b2, SignalBase t b3)
forall t a b c a b c.
(Num t, Ord t) =>
(Signal a
 -> Signal b -> Signal c -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY33 (\t1 :: Signal b1
t1 o1 :: Signal b2
o1 o2 :: Signal b3
o2 ->
                 (Signal b1
t1, b2 -> Signal b2 -> Signal b2
forall a. a -> Signal a -> Signal a
SYC.current b2
i1 Signal b2
o1, b3 -> Signal b3 -> Signal b3
forall a. a -> Signal a -> Signal a
SYC.current b3
i2 Signal b3
o2))
syncAndObs22 :: (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 (i1 :: b3
i1,i2 :: b4
i2)
  = (Signal b1
 -> Signal b2
 -> Signal b3
 -> Signal b4
 -> (Signal b1, Signal b2, Signal b3, Signal 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 a b c d a b c d.
(Num t, Ord t) =>
(Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
embedSY44 (\t1 :: Signal b1
t1 t2 :: Signal b2
t2 o1 :: Signal b3
o1 o2 :: Signal b4
o2 ->
                 (Signal b1
t1, Signal b2
t2, b3 -> Signal b3 -> Signal b3
forall a. a -> Signal a -> Signal a
SYC.current b3
i1 Signal b3
o1, b4 -> Signal b4 -> Signal b4
forall a. a -> Signal a -> Signal a
SYC.current b4
i2 Signal b4
o2))
syncAndObs13 :: (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 (i1 :: b2
i1,i2 :: b3
i2,i3 :: b4
i3)
  = (Signal b1
 -> Signal b2
 -> Signal b3
 -> Signal b4
 -> (Signal b1, Signal b2, Signal b3, Signal 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 a b c d a b c d.
(Num t, Ord t) =>
(Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
embedSY44 (\t1 :: Signal b1
t1 o1 :: Signal b2
o1 o2 :: Signal b3
o2 o3 :: Signal b4
o3 ->
                 (Signal b1
t1, b2 -> Signal b2 -> Signal b2
forall a. a -> Signal a -> Signal a
SYC.current b2
i1 Signal b2
o1, b3 -> Signal b3 -> Signal b3
forall a. a -> Signal a -> Signal a
SYC.current b3
i2 Signal b3
o2, b4 -> Signal b4 -> Signal b4
forall a. a -> Signal a -> Signal a
SYC.current b4
i3 Signal b4
o3))

------------ INTERFACES ------------------

-- | Semantics-preserving translation to "ForSyDe.Atom.MoC.SY.Clocked" signals. At any
-- synchronization instant, triggering events are wrapped into a
-- 'ForSyDe.Atom.ExB.Absent.Prst' behavior, whereas absent ones are represented as
-- 'ForSyDe.Atom.ExB.Absent.Abst'. The output signals are tupled with a (pure)
-- 'ForSyDe.Atom.MoC.SY.SY' signal carrying the timestamps of the synchronization
-- points.
--
-- __OBS:__ check the documentation of "ForSyDe.Atom.MoC.SY.Clocked" for legal
-- multi-clock rate interactions.
--
-- Constructors: @toSY[1-4]@
--
-- >>> let s1 = RE.instant 1
-- >>> let s2 = RE.readSignal "{1@1, 2@2, 3@6, 4@8, 5@9}" :: RE.Signal Int
-- >>> toSYC2 s1 s2
-- ({0s,1s,2s,6s,8s,9s},{1,⟂,⟂,⟂,⟂,⟂},{⟂,1,2,3,4,5})
--
-- <<fig/moc-re-pattern-tosyc.png>>
toSYC2 :: (Num t, Ord t)
       => RE.SignalBase t a             -- ^ first input DE signal
       -> RE.SignalBase t b             -- ^ second input DE signal
       -> (SY.Signal t, SYC.Signal a, SYC.Signal b)
       -- ^ signal carrying timestamps tupled with the two output
       -- 'ForSyDe.Atom.MoC.SYC.SY' signals
toSYC1  :: (Num t, Ord t)
        => RE.SignalBase t a
        -> (SY.Signal t, SYC.Signal a)
toSYC3 :: (Num t, Ord t)
       => RE.SignalBase t a -> RE.SignalBase t b -> RE.SignalBase t c
       -> (SY.Signal t, SYC.Signal a, SYC.Signal b, SYC.Signal c)
toSYC4 :: (Num t, Ord t)
       => RE.SignalBase t a -> RE.SignalBase t b -> RE.SignalBase t c
       -> RE.SignalBase t d
       -> (SY.Signal t, SYC.Signal a, SYC.Signal b, SYC.Signal c, SYC.Signal d)

splitTs :: f (RE t a) -> (f (SY t), f (SY a))
splitTs s :: f (RE t a)
s = ((\(RE.RE t :: t
t a :: a
a) -> (t -> SY t
forall a. a -> SY a
SY.SY t
t, a -> SY a
forall a. a -> SY a
SY.SY a
a)) (RE t a -> (SY t, SY a)) -> f (RE t a) -> f (SY t, SY a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (RE t a)
s f (SY t, SY a) -> (f (SY t), f (SY a))
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
toSYC1 :: SignalBase t a -> (Signal t, Signal a)
toSYC1 = Stream (RE t (AbstExt a)) -> (Signal t, Signal a)
forall (f :: * -> *) t a.
Functor f =>
f (RE t a) -> (f (SY t), f (SY a))
splitTs (Stream (RE t (AbstExt a)) -> (Signal t, Signal a))
-> (SignalBase t a -> Stream (RE t (AbstExt a)))
-> SignalBase t a
-> (Signal t, Signal a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((RE t a -> RE t (AbstExt a))
-> SignalBase t a -> Stream (RE t (AbstExt a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((RE t a -> RE t (AbstExt a))
 -> SignalBase t a -> Stream (RE t (AbstExt a)))
-> ((a -> AbstExt a) -> RE t a -> RE t (AbstExt a))
-> (a -> AbstExt a)
-> SignalBase t a
-> Stream (RE t (AbstExt a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> AbstExt a) -> RE t a -> RE t (AbstExt a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap) a -> AbstExt a
forall a. a -> AbstExt a
AE.Prst
toSYC2 :: SignalBase t a -> SignalBase t b -> (Signal t, Signal a, Signal b)
toSYC2 s1 :: SignalBase t a
s1 s2 :: SignalBase t b
s2
  = let (sy1 :: (Signal t, Signal a)
sy1,sy2 :: (Signal t, Signal b)
sy2) = (Stream (RE t (AbstExt a)) -> (Signal t, Signal a)
forall (f :: * -> *) t a.
Functor f =>
f (RE t a) -> (f (SY t), f (SY a))
splitTs,Stream (RE t (AbstExt b)) -> (Signal t, Signal b)
forall (f :: * -> *) t a.
Functor f =>
f (RE t a) -> (f (SY t), f (SY a))
splitTs) (Stream (RE t (AbstExt a)) -> (Signal t, Signal a),
 Stream (RE t (AbstExt b)) -> (Signal t, Signal b))
-> (Stream (RE t (AbstExt a)), Stream (RE t (AbstExt b)))
-> ((Signal t, Signal a), (Signal t, Signal b))
forall a1 b1 a2 b2. (a1 -> b1, a2 -> b2) -> (a1, a2) -> (b1, b2)
$$ ([a] -> [b] -> ([AbstExt a], [AbstExt b]))
-> SignalBase t a
-> SignalBase t b
-> (Stream (RE t (AbstExt a)), Stream (RE t (AbstExt b)))
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 [a] -> [b] -> ([AbstExt a], [AbstExt b])
forall a a. [a] -> [a] -> ([AbstExt a], [AbstExt a])
syncf SignalBase t a
s1 SignalBase t b
s2
    in  ((Signal t, Signal a) -> Signal t
forall a b. (a, b) -> a
fst,(Signal t, Signal a) -> Signal a
forall a b. (a, b) -> b
snd,(Signal t, Signal b) -> Signal b
forall a b. (a, b) -> b
snd) ((Signal t, Signal a) -> Signal t,
 (Signal t, Signal a) -> Signal a, (Signal t, Signal b) -> Signal b)
-> ((Signal t, Signal a), (Signal t, Signal a),
    (Signal t, Signal b))
-> (Signal t, Signal a, Signal b)
forall t1 a t2 b t3 c.
(t1 -> a, t2 -> b, t3 -> c) -> (t1, t2, t3) -> (a, b, c)
$$$ ((Signal t, Signal a)
sy1,(Signal t, Signal a)
sy1,(Signal t, Signal b)
sy2)
  where syncf :: [a] -> [a] -> ([AbstExt a], [AbstExt a])
syncf []  []  = ([AbstExt a
forall a. AbstExt a
AE.Abst],   [AbstExt a
forall a. AbstExt a
AE.Abst]  )
        syncf [x :: a
x] []  = ([a -> AbstExt a
forall a. a -> AbstExt a
AE.Prst a
x], [AbstExt a
forall a. AbstExt a
AE.Abst]  )
        syncf []  [x :: a
x] = ([AbstExt a
forall a. AbstExt a
AE.Abst],   [a -> AbstExt a
forall a. a -> AbstExt a
AE.Prst a
x])
        syncf [x :: a
x] [y :: a
y] = ([a -> AbstExt a
forall a. a -> AbstExt a
AE.Prst a
x], [a -> AbstExt a
forall a. a -> AbstExt a
AE.Prst a
y])
toSYC3 :: SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> (Signal t, Signal a, Signal b, Signal c)
toSYC3 s1 :: SignalBase t a
s1 s2 :: SignalBase t b
s2 s3 :: SignalBase t c
s3
  = let (sy1 :: (Signal t, Signal a)
sy1,sy2 :: (Signal t, Signal b)
sy2,sy3 :: (Signal t, Signal c)
sy3) = (Stream (RE t (AbstExt a)) -> (Signal t, Signal a)
forall (f :: * -> *) t a.
Functor f =>
f (RE t a) -> (f (SY t), f (SY a))
splitTs,Stream (RE t (AbstExt b)) -> (Signal t, Signal b)
forall (f :: * -> *) t a.
Functor f =>
f (RE t a) -> (f (SY t), f (SY a))
splitTs,Stream (RE t (AbstExt c)) -> (Signal t, Signal c)
forall (f :: * -> *) t a.
Functor f =>
f (RE t a) -> (f (SY t), f (SY a))
splitTs) (Stream (RE t (AbstExt a)) -> (Signal t, Signal a),
 Stream (RE t (AbstExt b)) -> (Signal t, Signal b),
 Stream (RE t (AbstExt c)) -> (Signal t, Signal c))
-> (Stream (RE t (AbstExt a)), Stream (RE t (AbstExt b)),
    Stream (RE t (AbstExt c)))
-> ((Signal t, Signal a), (Signal t, Signal b),
    (Signal t, Signal c))
forall t1 a t2 b t3 c.
(t1 -> a, t2 -> b, t3 -> c) -> (t1, t2, t3) -> (a, b, c)
$$$ ([a] -> [b] -> [c] -> ([AbstExt a], [AbstExt b], [AbstExt c]))
-> SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> (Stream (RE t (AbstExt a)), Stream (RE t (AbstExt b)),
    Stream (RE t (AbstExt c)))
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 [a] -> [b] -> [c] -> ([AbstExt a], [AbstExt b], [AbstExt c])
forall a a a.
[a] -> [a] -> [a] -> ([AbstExt a], [AbstExt a], [AbstExt a])
syncf SignalBase t a
s1 SignalBase t b
s2 SignalBase t c
s3
    in  ((Signal t, Signal a) -> Signal t
forall a b. (a, b) -> a
fst,(Signal t, Signal a) -> Signal a
forall a b. (a, b) -> b
snd,(Signal t, Signal b) -> Signal b
forall a b. (a, b) -> b
snd,(Signal t, Signal c) -> Signal c
forall a b. (a, b) -> b
snd) ((Signal t, Signal a) -> Signal t,
 (Signal t, Signal a) -> Signal a, (Signal t, Signal b) -> Signal b,
 (Signal t, Signal c) -> Signal c)
-> ((Signal t, Signal a), (Signal t, Signal a),
    (Signal t, Signal b), (Signal t, Signal c))
-> (Signal t, Signal a, Signal b, Signal c)
forall t1 a t2 b t3 c t4 d.
(t1 -> a, t2 -> b, t3 -> c, t4 -> d)
-> (t1, t2, t3, t4) -> (a, b, c, d)
$$$$ ((Signal t, Signal a)
sy1,(Signal t, Signal a)
sy1,(Signal t, Signal b)
sy2,(Signal t, Signal c)
sy3)  
  where syncf :: [a] -> [a] -> [a] -> ([AbstExt a], [AbstExt a], [AbstExt a])
syncf x :: [a]
x y :: [a]
y z :: [a]
z  = ([a] -> [AbstExt a]
forall a. [a] -> [AbstExt a]
lToA [a]
x, [a] -> [AbstExt a]
forall a. [a] -> [AbstExt a]
lToA [a]
y, [a] -> [AbstExt a]
forall a. [a] -> [AbstExt a]
lToA [a]
z)
        lToA :: [a] -> [AbstExt a]
lToA []  = [AbstExt a
forall a. AbstExt a
AE.Abst]
        lToA [x :: a
x] = [a -> AbstExt a
forall a. a -> AbstExt a
AE.Prst a
x]
toSYC4 :: SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> SignalBase t d
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
toSYC4 s1 :: SignalBase t a
s1 s2 :: SignalBase t b
s2 s3 :: SignalBase t c
s3 s4 :: SignalBase t d
s4  
  = let (sy1 :: (Signal t, Signal a)
sy1,sy2 :: (Signal t, Signal b)
sy2,sy3 :: (Signal t, Signal c)
sy3,sy4 :: (Signal t, Signal d)
sy4) = (Stream (RE t (AbstExt a)) -> (Signal t, Signal a)
forall (f :: * -> *) t a.
Functor f =>
f (RE t a) -> (f (SY t), f (SY a))
splitTs,Stream (RE t (AbstExt b)) -> (Signal t, Signal b)
forall (f :: * -> *) t a.
Functor f =>
f (RE t a) -> (f (SY t), f (SY a))
splitTs,Stream (RE t (AbstExt c)) -> (Signal t, Signal c)
forall (f :: * -> *) t a.
Functor f =>
f (RE t a) -> (f (SY t), f (SY a))
splitTs,Stream (RE t (AbstExt d)) -> (Signal t, Signal d)
forall (f :: * -> *) t a.
Functor f =>
f (RE t a) -> (f (SY t), f (SY a))
splitTs)
                            (Stream (RE t (AbstExt a)) -> (Signal t, Signal a),
 Stream (RE t (AbstExt b)) -> (Signal t, Signal b),
 Stream (RE t (AbstExt c)) -> (Signal t, Signal c),
 Stream (RE t (AbstExt d)) -> (Signal t, Signal d))
-> (Stream (RE t (AbstExt a)), Stream (RE t (AbstExt b)),
    Stream (RE t (AbstExt c)), Stream (RE t (AbstExt d)))
-> ((Signal t, Signal a), (Signal t, Signal b),
    (Signal t, Signal c), (Signal t, Signal d))
forall t1 a t2 b t3 c t4 d.
(t1 -> a, t2 -> b, t3 -> c, t4 -> d)
-> (t1, t2, t3, t4) -> (a, b, c, d)
$$$$ ([a]
 -> [b]
 -> [c]
 -> [d]
 -> ([AbstExt a], [AbstExt b], [AbstExt c], [AbstExt d]))
-> SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> SignalBase t d
-> (Stream (RE t (AbstExt a)), Stream (RE t (AbstExt b)),
    Stream (RE t (AbstExt c)), Stream (RE t (AbstExt d)))
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 [a]
-> [b]
-> [c]
-> [d]
-> ([AbstExt a], [AbstExt b], [AbstExt c], [AbstExt d])
forall a a a a.
[a]
-> [a]
-> [a]
-> [a]
-> ([AbstExt a], [AbstExt a], [AbstExt a], [AbstExt a])
syncf SignalBase t a
s1 SignalBase t b
s2 SignalBase t c
s3 SignalBase t d
s4
    in  ((Signal t, Signal a) -> Signal t
forall a b. (a, b) -> a
fst,(Signal t, Signal a) -> Signal a
forall a b. (a, b) -> b
snd,(Signal t, Signal b) -> Signal b
forall a b. (a, b) -> b
snd,(Signal t, Signal c) -> Signal c
forall a b. (a, b) -> b
snd,(Signal t, Signal d) -> Signal d
forall a b. (a, b) -> b
snd) ((Signal t, Signal a) -> Signal t,
 (Signal t, Signal a) -> Signal a, (Signal t, Signal b) -> Signal b,
 (Signal t, Signal c) -> Signal c, (Signal t, Signal d) -> Signal d)
-> ((Signal t, Signal a), (Signal t, Signal a),
    (Signal t, Signal b), (Signal t, Signal c), (Signal t, Signal d))
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
forall t1 a t2 b t3 c t4 d t5 e.
(t1 -> a, t2 -> b, t3 -> c, t4 -> d, t5 -> e)
-> (t1, t2, t3, t4, t5) -> (a, b, c, d, e)
$$$$$ ((Signal t, Signal a)
sy1,(Signal t, Signal a)
sy1,(Signal t, Signal b)
sy2,(Signal t, Signal c)
sy3,(Signal t, Signal d)
sy4) 
  where syncf :: [a]
-> [a]
-> [a]
-> [a]
-> ([AbstExt a], [AbstExt a], [AbstExt a], [AbstExt a])
syncf x :: [a]
x y :: [a]
y z :: [a]
z a :: [a]
a = ([a] -> [AbstExt a]
forall a. [a] -> [AbstExt a]
lToA [a]
x, [a] -> [AbstExt a]
forall a. [a] -> [AbstExt a]
lToA [a]
y, [a] -> [AbstExt a]
forall a. [a] -> [AbstExt a]
lToA [a]
z, [a] -> [AbstExt a]
forall a. [a] -> [AbstExt a]
lToA [a]
a)
        lToA :: [a] -> [AbstExt a]
lToA []  = [AbstExt a
forall a. AbstExt a
AE.Abst]
        lToA [x :: a
x] = [a -> AbstExt a
forall a. a -> AbstExt a
AE.Prst a
x]

-- | Semantics-preserving translation from "ForSyDe.Atom.MoC.SY.Clocked" signals.
-- 'ForSyDe.Atom.ExB.Absent.Prst' events are propagated, whereas
-- 'ForSyDe.Atom.ExB.Absent.Abst' ones are cleaned from the output. The first signal
-- needs to be a (pure) 'ForSyDe.Atom.MoC.SY.SY' signal describing the timestamps of
-- the synchronization points.
--
-- __OBS:__ This process has cleaning behavior. It needs to be avoided from the
-- datapath of any feedback loop!
--
-- Constructors: @fromSY@, @fromSY2@, @fromSY3@, @fromSY4@.
--
-- >>> let s1 = SY.signal [0,3,4,6,9] :: SY.Signal DE.TimeStamp
-- >>> let s2 = SY.signal [Prst 1,Prst 2,Abst,Prst 4,Prst 5]
-- >>> fromSYC1 s1 s2
-- {1@0s,2@3s,4@6s,5@9s}
--
-- <<fig/moc-re-pattern-fromsyc.png>>
fromSYC2 :: (Num t, Ord t)
         => SY.Signal t
         -- ^ SY signal carrying 'ForSyDe.Atom.MoC.RE.RE' timestamps
         -> SYC.Signal a                -- ^ first input SYC signal
         -> SYC.Signal b                -- ^ second input SYC signal
         -> (RE.SignalBase t a, RE.SignalBase t b)
         -- ^ two output 'ForSyDe.Atom.MoC.DE.DE' signals
fromSYC1 :: (Num t, Ord t)
         => SY.Signal t -> SYC.Signal a
         -> RE.SignalBase t a
fromSYC3 :: (Num t, Ord t)
         => SY.Signal t -> SYC.Signal a -> SYC.Signal b -> SYC.Signal c 
         -> (RE.SignalBase t a, RE.SignalBase t b, RE.SignalBase t c)
fromSYC4 :: (Num t, Ord t)
  => SY.Signal t -> SYC.Signal a -> SYC.Signal b -> SYC.Signal c -> SYC.Signal d 
  -> (RE.SignalBase t a, RE.SignalBase t b, RE.SignalBase t c, RE.SignalBase t d)
         
eventToDE :: SY t -> SY a -> RE t a
eventToDE (SY.SY t :: t
t) (SY.SY a :: a
a) = t -> a -> RE t a
forall t a. (Num t, Ord t, Eq t) => t -> a -> RE t a
RE.RE t
t a
a
cleanAbst :: [AbstExt a] -> [a]
cleanAbst [AE.Prst x :: a
x] = [a
x]
cleanAbst [AE.Abst]   = []

fromSYC1 :: Signal t -> Signal a -> SignalBase t a
fromSYC1 ts :: Signal t
ts s1 :: Signal a
s1          = ([AbstExt a] -> [a]) -> SignalBase t (AbstExt a) -> SignalBase t a
forall t a1 b1.
(Ord t, Num t) =>
([a1] -> [b1]) -> SignalBase t a1 -> SignalBase t b1
comb11 [AbstExt a] -> [a]
forall a. [AbstExt a] -> [a]
cleanAbst (SignalBase t (AbstExt a) -> SignalBase t a)
-> SignalBase t (AbstExt a) -> SignalBase t a
forall a b. (a -> b) -> a -> b
$ SY t -> SY (AbstExt a) -> RE t (AbstExt a)
forall t a. (Num t, Ord t) => SY t -> SY a -> RE t a
eventToDE (SY t -> SY (AbstExt a) -> RE t (AbstExt a))
-> Signal t -> Stream (SY (AbstExt a) -> RE t (AbstExt a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Signal t
ts Stream (SY (AbstExt a) -> RE t (AbstExt a))
-> Signal a -> SignalBase t (AbstExt a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Signal a
s1
fromSYC2 :: Signal t
-> Signal a -> Signal b -> (SignalBase t a, SignalBase t b)
fromSYC2 ts :: Signal t
ts s1 :: Signal a
s1 s2 :: Signal b
s2       = (Signal t -> Signal a -> SignalBase t a
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts Signal a
s1, Signal t -> Signal b -> SignalBase t b
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts Signal b
s2)
fromSYC3 :: Signal t
-> Signal a
-> Signal b
-> Signal c
-> (SignalBase t a, SignalBase t b, SignalBase t c)
fromSYC3 ts :: Signal t
ts s1 :: Signal a
s1 s2 :: Signal b
s2 s3 :: Signal c
s3    = (Signal t -> Signal a -> SignalBase t a
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts Signal a
s1, Signal t -> Signal b -> SignalBase t b
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts Signal b
s2, Signal t -> Signal c -> SignalBase t c
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts Signal c
s3)
fromSYC4 :: Signal t
-> Signal a
-> Signal b
-> Signal c
-> Signal d
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
fromSYC4 ts :: Signal t
ts s1 :: Signal a
s1 s2 :: Signal b
s2 s3 :: Signal c
s3 s4 :: Signal d
s4 = (Signal t -> Signal a -> SignalBase t a
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts Signal a
s1, Signal t -> Signal b -> SignalBase t b
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts Signal b
s2, Signal t -> Signal c -> SignalBase t c
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts Signal c
s3,
                           Signal t -> Signal d -> SignalBase t d
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts Signal d
s4)

reToDE :: RE t a -> DE t a
reToDE (RE.RE t :: t
t a :: a
a) = (t -> a -> DE t a
forall t a. (Num t, Ord t, Eq t) => t -> a -> DE t a
DE.DE t
t a
a)
toDE1 :: f (RE t a) -> f (DE t a)
toDE1 s1 :: f (RE t a)
s1 = (RE t a -> DE t a) -> f (RE t a) -> f (DE t a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RE t a -> DE t a
forall t a. RE t a -> DE t a
reToDE f (RE t a)
s1
-- | Syntax-preserving transformation to the original conservative
-- "ForSyDe.Atom.MoC.DE" MoC. It is __not__ semantics-preserving because "instant"
-- events are re-interpreted as "persistent".
--
-- __OBS:__ all input signals need to start from global time 0.
--
-- >>> let s1 = RE.readSignal "{1@0, 2@2, 3@6, 4@8, 5@9}" :: RE.Signal Int
-- >>> let s2 = RE.readSignal "{1@0, 2@3, 3@4, 4@8, 5@10}" :: RE.Signal Int
-- >>> toDE2 s1 s2
-- ({1@0s,2@2s,3@6s,4@8s,5@9s},{1@0s,2@3s,3@4s,4@8s,5@10s})
--
-- <<fig/moc-re-pattern-tode.png>>
toDE2 :: f (RE t a) -> f (RE t a) -> (f (DE t a), f (DE t a))
toDE2 s1 :: f (RE t a)
s1 s2 :: f (RE t a)
s2 = (f (RE t a) -> f (DE t a)
forall (f :: * -> *) t a. Functor f => f (RE t a) -> f (DE t a)
toDE1 f (RE t a)
s1, f (RE t a) -> f (DE t a)
forall (f :: * -> *) t a. Functor f => f (RE t a) -> f (DE t a)
toDE1 f (RE t a)
s2)
toDE3 :: f (RE t a)
-> f (RE t a) -> f (RE t a) -> (f (DE t a), f (DE t a), f (DE t a))
toDE3 s1 :: f (RE t a)
s1 s2 :: f (RE t a)
s2 s3 :: f (RE t a)
s3 = (f (RE t a) -> f (DE t a)
forall (f :: * -> *) t a. Functor f => f (RE t a) -> f (DE t a)
toDE1 f (RE t a)
s1, f (RE t a) -> f (DE t a)
forall (f :: * -> *) t a. Functor f => f (RE t a) -> f (DE t a)
toDE1 f (RE t a)
s2, f (RE t a) -> f (DE t a)
forall (f :: * -> *) t a. Functor f => f (RE t a) -> f (DE t a)
toDE1 f (RE t a)
s3)
toDE4 :: f (RE t a)
-> f (RE t a)
-> f (RE t a)
-> f (RE t a)
-> (f (DE t a), f (DE t a), f (DE t a), f (DE t a))
toDE4 s1 :: f (RE t a)
s1 s2 :: f (RE t a)
s2 s3 :: f (RE t a)
s3 s4 :: f (RE t a)
s4 = (f (RE t a) -> f (DE t a)
forall (f :: * -> *) t a. Functor f => f (RE t a) -> f (DE t a)
toDE1 f (RE t a)
s1, f (RE t a) -> f (DE t a)
forall (f :: * -> *) t a. Functor f => f (RE t a) -> f (DE t a)
toDE1 f (RE t a)
s2, f (RE t a) -> f (DE t a)
forall (f :: * -> *) t a. Functor f => f (RE t a) -> f (DE t a)
toDE1 f (RE t a)
s3, f (RE t a) -> f (DE t a)
forall (f :: * -> *) t a. Functor f => f (RE t a) -> f (DE t a)
toDE1 f (RE t a)
s4)

deToRE :: DE t a -> RE t a
deToRE (DE.DE t :: t
t a :: a
a) = (t -> a -> RE t a
forall t a. (Num t, Ord t, Eq t) => t -> a -> RE t a
RE.RE t
t a
a)
fromDE1 :: f (DE t a) -> f (RE t a)
fromDE1 s1 :: f (DE t a)
s1 = (DE t a -> RE t a) -> f (DE t a) -> f (RE t a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DE t a -> RE t a
forall t a. DE t a -> RE t a
deToRE f (DE t a)
s1
-- | Syntax-preserving transformation from the original conservative
-- "ForSyDe.Atom.MoC.DE" MoC. It is __not__ semantics-preserving because "persistent"
-- events are re-interpreted as "instant".
--
-- __OBS:__ all input signals will start at global time 0.
--
-- >>> let s1 = DE.readSignal "{1@0, 2@2, 3@6, 4@8, 5@9}" :: DE.Signal Int
-- >>> let s2 = DE.readSignal "{1@0, 2@3, 3@4, 4@8, 5@10}" :: DE.Signal Int
-- >>> fromDE2 s1 s2
-- ({1@0s,2@2s,3@6s,4@8s,5@9s},{1@0s,2@3s,3@4s,4@8s,5@10s})
--
-- <<fig/moc-re-pattern-fromde.png>>
fromDE2 :: f (DE t a) -> f (DE t a) -> (f (RE t a), f (RE t a))
fromDE2 s1 :: f (DE t a)
s1 s2 :: f (DE t a)
s2 = (f (DE t a) -> f (RE t a)
forall (f :: * -> *) t a. Functor f => f (DE t a) -> f (RE t a)
fromDE1 f (DE t a)
s1, f (DE t a) -> f (RE t a)
forall (f :: * -> *) t a. Functor f => f (DE t a) -> f (RE t a)
fromDE1 f (DE t a)
s2)
fromDE3 :: f (DE t a)
-> f (DE t a) -> f (DE t a) -> (f (RE t a), f (RE t a), f (RE t a))
fromDE3 s1 :: f (DE t a)
s1 s2 :: f (DE t a)
s2 s3 :: f (DE t a)
s3 = (f (DE t a) -> f (RE t a)
forall (f :: * -> *) t a. Functor f => f (DE t a) -> f (RE t a)
fromDE1 f (DE t a)
s1, f (DE t a) -> f (RE t a)
forall (f :: * -> *) t a. Functor f => f (DE t a) -> f (RE t a)
fromDE1 f (DE t a)
s2, f (DE t a) -> f (RE t a)
forall (f :: * -> *) t a. Functor f => f (DE t a) -> f (RE t a)
fromDE1 f (DE t a)
s3)
fromDE4 :: f (DE t a)
-> f (DE t a)
-> f (DE t a)
-> f (DE t a)
-> (f (RE t a), f (RE t a), f (RE t a), f (RE t a))
fromDE4 s1 :: f (DE t a)
s1 s2 :: f (DE t a)
s2 s3 :: f (DE t a)
s3 s4 :: f (DE t a)
s4 = (f (DE t a) -> f (RE t a)
forall (f :: * -> *) t a. Functor f => f (DE t a) -> f (RE t a)
fromDE1 f (DE t a)
s1, f (DE t a) -> f (RE t a)
forall (f :: * -> *) t a. Functor f => f (DE t a) -> f (RE t a)
fromDE1 f (DE t a)
s2, f (DE t a) -> f (RE t a)
forall (f :: * -> *) t a. Functor f => f (DE t a) -> f (RE t a)
fromDE1 f (DE t a)
s3, f (DE t a) -> f (RE t a)
forall (f :: * -> *) t a. Functor f => f (DE t a) -> f (RE t a)
fromDE1 f (DE t a)
s4)

------- HYBRID PROCESSES -------

-- | Embeds a "ForSyDe.Atom.MoC.SY.Clocked" process inside a 'ForSyDe.Atom.MoC.RE.RE'
-- environment. Internally, it synchronizes the input signals, translates them to
-- clocked SY (see 'toSYC2'), feeds them to a SY process and translates the result
-- back to 'ForSyDe.Atom.MoC.RE.RE' (see 'fromSYC2') using the same input tags. Seen
-- from outside, this process behaves like a RE process with "instantaneous response".
--
-- Constructors: @embedSY[1-4][1-4]@.
--
-- For the following example, see the difference between its output
-- and the one of 'ForSyDe.Atom.MoC.DE.React.stated22'
--
-- >>> let s1 = readSignal "{1@0, 2@2, 3@6, 4@8, 5@9}" :: RE.Signal Int
-- >>> let s2 = readSignal "{1@0, 2@2, 3@6, 4@8, 5@9}" :: RE.Signal Int
-- >>> embedSY21 (SYC.stated21 (\s a b -> a + b - s) 1) s1 s2
-- {1@0s,1@2s,3@6s,3@8s,5@9s}
--
-- <<fig/moc-re-pattern-embedsy.png>>
--
-- __OBS:__ according to the "ForSyDe.Atom.MoC.SY.Clocked" MoC all inputs signals need
-- to be sichronized (i.e. have the same clock rate), otherwise their interaction is
-- illegal.
--
-- >> let s1 = readSignal "{1@0, 2@2, 3@6, 4@8, 5@9}" :: RE.Signal Int
-- >> let s2 = readSignal "{1@0, 2@2, 3@7, 4@8, 5@9}" :: RE.Signal Int
-- >> embedSY21 (SYC.stated21 (\s a b -> a + b - s) 1) s1 s2
-- > {1@0s,1@2s,3@6s,*** Exception: [ExB.Absent] Illegal occurrence of an absent and present event
embedSY22 :: (Num t, Ord t)
          => (SYC.Signal a1 -> SYC.Signal a2
              -> (SYC.Signal b1, SYC.Signal b2))
          -- ^ 'ForSyDe.Atom.MoC.SY.SY' process
          -> RE.SignalBase t a1 -- ^ first input DE signal
          -> RE.SignalBase t a2 -- ^ second input DE signal 
          -> (RE.SignalBase t b1, RE.SignalBase t b2)
          -- ^ two output 'ForSyDe.Atom.MoC.DE.DE' signals

embedSY11 :: (Signal a -> Signal a) -> Stream (RE t a) -> SignalBase t a
embedSY11 syproc :: Signal a -> Signal a
syproc de1 :: Stream (RE t a)
de1
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1) = Stream (RE t a) -> (Signal t, Signal a)
forall t a.
(Num t, Ord t) =>
SignalBase t a -> (Signal t, Signal a)
toSYC1 Stream (RE t a)
de1
    in  Signal t -> Signal a -> SignalBase t a
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts (Signal a -> SignalBase t a) -> Signal a -> SignalBase t a
forall a b. (a -> b) -> a -> b
$     Signal a -> Signal a
syproc Signal a
sy1 
embedSY12 :: (Signal a -> (Signal a, Signal b))
-> Stream (RE t a) -> (SignalBase t a, SignalBase t b)
embedSY12 syproc :: Signal a -> (Signal a, Signal b)
syproc de1 :: Stream (RE t a)
de1
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1) = Stream (RE t a) -> (Signal t, Signal a)
forall t a.
(Num t, Ord t) =>
SignalBase t a -> (Signal t, Signal a)
toSYC1 Stream (RE t a)
de1
    in  Signal t
-> Signal a -> Signal b -> (SignalBase t a, SignalBase t b)
forall t a b.
(Num t, Ord t) =>
Signal t
-> Signal a -> Signal b -> (SignalBase t a, SignalBase t b)
fromSYC2 Signal t
ts (Signal a -> Signal b -> (SignalBase t a, SignalBase t b))
-> (Signal a, Signal b) -> (SignalBase t a, SignalBase t b)
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
><   Signal a -> (Signal a, Signal b)
syproc Signal a
sy1
embedSY13 :: (Signal a -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY13 syproc :: Signal a -> (Signal a, Signal b, Signal c)
syproc de1 :: Stream (RE t a)
de1
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1) = Stream (RE t a) -> (Signal t, Signal a)
forall t a.
(Num t, Ord t) =>
SignalBase t a -> (Signal t, Signal a)
toSYC1 Stream (RE t a)
de1
    in  Signal t
-> Signal a
-> Signal b
-> Signal c
-> (SignalBase t a, SignalBase t b, SignalBase t c)
forall t a b c.
(Num t, Ord t) =>
Signal t
-> Signal a
-> Signal b
-> Signal c
-> (SignalBase t a, SignalBase t b, SignalBase t c)
fromSYC3 Signal t
ts (Signal a
 -> Signal b
 -> Signal c
 -> (SignalBase t a, SignalBase t b, SignalBase t c))
-> (Signal a, Signal b, Signal c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
><<  Signal a -> (Signal a, Signal b, Signal c)
syproc Signal a
sy1
embedSY14 :: (Signal a -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
embedSY14 syproc :: Signal a -> (Signal a, Signal b, Signal c, Signal d)
syproc de1 :: Stream (RE t a)
de1
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1) = Stream (RE t a) -> (Signal t, Signal a)
forall t a.
(Num t, Ord t) =>
SignalBase t a -> (Signal t, Signal a)
toSYC1 Stream (RE t a)
de1
    in  Signal t
-> Signal a
-> Signal b
-> Signal c
-> Signal d
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
forall t a b c d.
(Num t, Ord t) =>
Signal t
-> Signal a
-> Signal b
-> Signal c
-> Signal d
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
fromSYC4 Signal t
ts (Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (SignalBase t a, SignalBase t b, SignalBase t c,
     SignalBase t d))
-> (Signal a, Signal b, Signal c, Signal d)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
forall t1 t2 t3 t4 t5.
(t1 -> t2 -> t3 -> t4 -> t5) -> (t1, t2, t3, t4) -> t5
><<< Signal a -> (Signal a, Signal b, Signal c, Signal d)
syproc Signal a
sy1

embedSY21 :: (Signal a -> Signal b -> Signal a)
-> Stream (RE t a) -> Stream (RE t b) -> SignalBase t a
embedSY21 syproc :: Signal a -> Signal b -> Signal a
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2) = Stream (RE t a)
-> Stream (RE t b) -> (Signal t, Signal a, Signal b)
forall t a b.
(Num t, Ord t) =>
SignalBase t a -> SignalBase t b -> (Signal t, Signal a, Signal b)
toSYC2 Stream (RE t a)
de1 Stream (RE t b)
de2
    in  Signal t -> Signal a -> SignalBase t a
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts (Signal a -> SignalBase t a) -> Signal a -> SignalBase t a
forall a b. (a -> b) -> a -> b
$     Signal a -> Signal b -> Signal a
syproc Signal a
sy1 Signal b
sy2
embedSY22 :: (Signal a1 -> Signal a2 -> (Signal b1, Signal b2))
-> SignalBase t a1
-> SignalBase t a2
-> (SignalBase t b1, SignalBase t b2)
embedSY22 syproc :: Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
syproc de1 :: SignalBase t a1
de1 de2 :: SignalBase t a2
de2
  = let (ts :: Signal t
ts, sy1 :: Signal a1
sy1, sy2 :: Signal a2
sy2) = SignalBase t a1
-> SignalBase t a2 -> (Signal t, Signal a1, Signal a2)
forall t a b.
(Num t, Ord t) =>
SignalBase t a -> SignalBase t b -> (Signal t, Signal a, Signal b)
toSYC2 SignalBase t a1
de1 SignalBase t a2
de2
    in  Signal t
-> Signal b1 -> Signal b2 -> (SignalBase t b1, SignalBase t b2)
forall t a b.
(Num t, Ord t) =>
Signal t
-> Signal a -> Signal b -> (SignalBase t a, SignalBase t b)
fromSYC2 Signal t
ts (Signal b1 -> Signal b2 -> (SignalBase t b1, SignalBase t b2))
-> (Signal b1, Signal b2) -> (SignalBase t b1, SignalBase t b2)
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
><   Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
syproc Signal a1
sy1 Signal a2
sy2
embedSY23 :: (Signal a -> Signal b -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY23 syproc :: Signal a -> Signal b -> (Signal a, Signal b, Signal c)
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2) = Stream (RE t a)
-> Stream (RE t b) -> (Signal t, Signal a, Signal b)
forall t a b.
(Num t, Ord t) =>
SignalBase t a -> SignalBase t b -> (Signal t, Signal a, Signal b)
toSYC2 Stream (RE t a)
de1 Stream (RE t b)
de2
    in  Signal t
-> Signal a
-> Signal b
-> Signal c
-> (SignalBase t a, SignalBase t b, SignalBase t c)
forall t a b c.
(Num t, Ord t) =>
Signal t
-> Signal a
-> Signal b
-> Signal c
-> (SignalBase t a, SignalBase t b, SignalBase t c)
fromSYC3 Signal t
ts (Signal a
 -> Signal b
 -> Signal c
 -> (SignalBase t a, SignalBase t b, SignalBase t c))
-> (Signal a, Signal b, Signal c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
><<  Signal a -> Signal b -> (Signal a, Signal b, Signal c)
syproc Signal a
sy1 Signal b
sy2
embedSY24 :: (Signal a -> Signal b -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> Stream (RE t b)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
embedSY24 syproc :: Signal a -> Signal b -> (Signal a, Signal b, Signal c, Signal d)
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2) = Stream (RE t a)
-> Stream (RE t b) -> (Signal t, Signal a, Signal b)
forall t a b.
(Num t, Ord t) =>
SignalBase t a -> SignalBase t b -> (Signal t, Signal a, Signal b)
toSYC2 Stream (RE t a)
de1 Stream (RE t b)
de2
    in  Signal t
-> Signal a
-> Signal b
-> Signal c
-> Signal d
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
forall t a b c d.
(Num t, Ord t) =>
Signal t
-> Signal a
-> Signal b
-> Signal c
-> Signal d
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
fromSYC4 Signal t
ts (Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (SignalBase t a, SignalBase t b, SignalBase t c,
     SignalBase t d))
-> (Signal a, Signal b, Signal c, Signal d)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
forall t1 t2 t3 t4 t5.
(t1 -> t2 -> t3 -> t4 -> t5) -> (t1, t2, t3, t4) -> t5
><<< Signal a -> Signal b -> (Signal a, Signal b, Signal c, Signal d)
syproc Signal a
sy1 Signal b
sy2

embedSY31 :: (Signal a -> Signal b -> Signal c -> Signal a)
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> SignalBase t a
embedSY31 syproc :: Signal a -> Signal b -> Signal c -> Signal a
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2 de3 :: Stream (RE t c)
de3
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2, sy3 :: Signal c
sy3) = Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (Signal t, Signal a, Signal b, Signal c)
forall t a b c.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> (Signal t, Signal a, Signal b, Signal c)
toSYC3 Stream (RE t a)
de1 Stream (RE t b)
de2 Stream (RE t c)
de3
    in  Signal t -> Signal a -> SignalBase t a
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts (Signal a -> SignalBase t a) -> Signal a -> SignalBase t a
forall a b. (a -> b) -> a -> b
$     Signal a -> Signal b -> Signal c -> Signal a
syproc Signal a
sy1 Signal b
sy2 Signal c
sy3
embedSY32 :: (Signal a -> Signal b -> Signal c -> (Signal a, Signal b))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b)
embedSY32 syproc :: Signal a -> Signal b -> Signal c -> (Signal a, Signal b)
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2 de3 :: Stream (RE t c)
de3
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2, sy3 :: Signal c
sy3) = Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (Signal t, Signal a, Signal b, Signal c)
forall t a b c.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> (Signal t, Signal a, Signal b, Signal c)
toSYC3 Stream (RE t a)
de1 Stream (RE t b)
de2 Stream (RE t c)
de3
    in  Signal t
-> Signal a -> Signal b -> (SignalBase t a, SignalBase t b)
forall t a b.
(Num t, Ord t) =>
Signal t
-> Signal a -> Signal b -> (SignalBase t a, SignalBase t b)
fromSYC2 Signal t
ts (Signal a -> Signal b -> (SignalBase t a, SignalBase t b))
-> (Signal a, Signal b) -> (SignalBase t a, SignalBase t b)
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
><   Signal a -> Signal b -> Signal c -> (Signal a, Signal b)
syproc Signal a
sy1 Signal b
sy2 Signal c
sy3
embedSY33 :: (Signal a
 -> Signal b -> Signal c -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY33 syproc :: Signal a -> Signal b -> Signal c -> (Signal a, Signal b, Signal c)
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2 de3 :: Stream (RE t c)
de3
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2, sy3 :: Signal c
sy3) = Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (Signal t, Signal a, Signal b, Signal c)
forall t a b c.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> (Signal t, Signal a, Signal b, Signal c)
toSYC3 Stream (RE t a)
de1 Stream (RE t b)
de2 Stream (RE t c)
de3
    in  Signal t
-> Signal a
-> Signal b
-> Signal c
-> (SignalBase t a, SignalBase t b, SignalBase t c)
forall t a b c.
(Num t, Ord t) =>
Signal t
-> Signal a
-> Signal b
-> Signal c
-> (SignalBase t a, SignalBase t b, SignalBase t c)
fromSYC3 Signal t
ts (Signal a
 -> Signal b
 -> Signal c
 -> (SignalBase t a, SignalBase t b, SignalBase t c))
-> (Signal a, Signal b, Signal c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
><<  Signal a -> Signal b -> Signal c -> (Signal a, Signal b, Signal c)
syproc Signal a
sy1 Signal b
sy2 Signal c
sy3
embedSY34 :: (Signal a
 -> Signal b
 -> Signal c
 -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
embedSY34 syproc :: Signal a
-> Signal b -> Signal c -> (Signal a, Signal b, Signal c, Signal d)
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2 de3 :: Stream (RE t c)
de3
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2, sy3 :: Signal c
sy3) = Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> (Signal t, Signal a, Signal b, Signal c)
forall t a b c.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> (Signal t, Signal a, Signal b, Signal c)
toSYC3 Stream (RE t a)
de1 Stream (RE t b)
de2 Stream (RE t c)
de3
    in  Signal t
-> Signal a
-> Signal b
-> Signal c
-> Signal d
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
forall t a b c d.
(Num t, Ord t) =>
Signal t
-> Signal a
-> Signal b
-> Signal c
-> Signal d
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
fromSYC4 Signal t
ts (Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (SignalBase t a, SignalBase t b, SignalBase t c,
     SignalBase t d))
-> (Signal a, Signal b, Signal c, Signal d)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
forall t1 t2 t3 t4 t5.
(t1 -> t2 -> t3 -> t4 -> t5) -> (t1, t2, t3, t4) -> t5
><<< Signal a
-> Signal b -> Signal c -> (Signal a, Signal b, Signal c, Signal d)
syproc Signal a
sy1 Signal b
sy2 Signal c
sy3

embedSY41 :: (Signal a -> Signal b -> Signal c -> Signal d -> Signal a)
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> SignalBase t a
embedSY41 syproc :: Signal a -> Signal b -> Signal c -> Signal d -> Signal a
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2 de3 :: Stream (RE t c)
de3 de4 :: Stream (RE t d)
de4
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2, sy3 :: Signal c
sy3, sy4 :: Signal d
sy4) = Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
forall t a b c d.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> SignalBase t d
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
toSYC4 Stream (RE t a)
de1 Stream (RE t b)
de2 Stream (RE t c)
de3 Stream (RE t d)
de4
    in  Signal t -> Signal a -> SignalBase t a
forall t a.
(Num t, Ord t) =>
Signal t -> Signal a -> SignalBase t a
fromSYC1 Signal t
ts (Signal a -> SignalBase t a) -> Signal a -> SignalBase t a
forall a b. (a -> b) -> a -> b
$     Signal a -> Signal b -> Signal c -> Signal d -> Signal a
syproc Signal a
sy1 Signal b
sy2 Signal c
sy3 Signal d
sy4
embedSY42 :: (Signal a
 -> Signal b -> Signal c -> Signal d -> (Signal a, Signal b))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (SignalBase t a, SignalBase t b)
embedSY42 syproc :: Signal a
-> Signal b -> Signal c -> Signal d -> (Signal a, Signal b)
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2 de3 :: Stream (RE t c)
de3 de4 :: Stream (RE t d)
de4
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2, sy3 :: Signal c
sy3, sy4 :: Signal d
sy4) = Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
forall t a b c d.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> SignalBase t d
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
toSYC4 Stream (RE t a)
de1 Stream (RE t b)
de2 Stream (RE t c)
de3 Stream (RE t d)
de4
    in  Signal t
-> Signal a -> Signal b -> (SignalBase t a, SignalBase t b)
forall t a b.
(Num t, Ord t) =>
Signal t
-> Signal a -> Signal b -> (SignalBase t a, SignalBase t b)
fromSYC2 Signal t
ts (Signal a -> Signal b -> (SignalBase t a, SignalBase t b))
-> (Signal a, Signal b) -> (SignalBase t a, SignalBase t b)
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
><   Signal a
-> Signal b -> Signal c -> Signal d -> (Signal a, Signal b)
syproc Signal a
sy1 Signal b
sy2 Signal c
sy3 Signal d
sy4
embedSY43 :: (Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (Signal a, Signal b, Signal c))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
embedSY43 syproc :: Signal a
-> Signal b
-> Signal c
-> Signal d
-> (Signal a, Signal b, Signal c)
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2 de3 :: Stream (RE t c)
de3 de4 :: Stream (RE t d)
de4
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2, sy3 :: Signal c
sy3, sy4 :: Signal d
sy4) = Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
forall t a b c d.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> SignalBase t d
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
toSYC4 Stream (RE t a)
de1 Stream (RE t b)
de2 Stream (RE t c)
de3 Stream (RE t d)
de4
    in  Signal t
-> Signal a
-> Signal b
-> Signal c
-> (SignalBase t a, SignalBase t b, SignalBase t c)
forall t a b c.
(Num t, Ord t) =>
Signal t
-> Signal a
-> Signal b
-> Signal c
-> (SignalBase t a, SignalBase t b, SignalBase t c)
fromSYC3 Signal t
ts (Signal a
 -> Signal b
 -> Signal c
 -> (SignalBase t a, SignalBase t b, SignalBase t c))
-> (Signal a, Signal b, Signal c)
-> (SignalBase t a, SignalBase t b, SignalBase t c)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
><<  Signal a
-> Signal b
-> Signal c
-> Signal d
-> (Signal a, Signal b, Signal c)
syproc Signal a
sy1 Signal b
sy2 Signal c
sy3 Signal d
sy4
embedSY44 :: (Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (Signal a, Signal b, Signal c, Signal d))
-> Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
embedSY44 syproc :: Signal a
-> Signal b
-> Signal c
-> Signal d
-> (Signal a, Signal b, Signal c, Signal d)
syproc de1 :: Stream (RE t a)
de1 de2 :: Stream (RE t b)
de2 de3 :: Stream (RE t c)
de3 de4 :: Stream (RE t d)
de4
  = let (ts :: Signal t
ts, sy1 :: Signal a
sy1, sy2 :: Signal b
sy2, sy3 :: Signal c
sy3, sy4 :: Signal d
sy4) = Stream (RE t a)
-> Stream (RE t b)
-> Stream (RE t c)
-> Stream (RE t d)
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
forall t a b c d.
(Num t, Ord t) =>
SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> SignalBase t d
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
toSYC4 Stream (RE t a)
de1 Stream (RE t b)
de2 Stream (RE t c)
de3 Stream (RE t d)
de4
    in  Signal t
-> Signal a
-> Signal b
-> Signal c
-> Signal d
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
forall t a b c d.
(Num t, Ord t) =>
Signal t
-> Signal a
-> Signal b
-> Signal c
-> Signal d
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
fromSYC4 Signal t
ts (Signal a
 -> Signal b
 -> Signal c
 -> Signal d
 -> (SignalBase t a, SignalBase t b, SignalBase t c,
     SignalBase t d))
-> (Signal a, Signal b, Signal c, Signal d)
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
forall t1 t2 t3 t4 t5.
(t1 -> t2 -> t3 -> t4 -> t5) -> (t1, t2, t3, t4) -> t5
><<< Signal a
-> Signal b
-> Signal c
-> Signal d
-> (Signal a, Signal b, Signal c, Signal d)
syproc Signal a
sy1 Signal b
sy2 Signal c
sy3 Signal d
sy4