{-# LANGUAGE PostfixOperators #-}
{-# OPTIONS_HADDOCK prune #-}
---------------------------------------------------------------------
-- |
-- Module      :  ForSyDe.Atom.MoC.SY.Clocked
-- Copyright   :  (c) George Ungureanu, 2020
-- License     :  BSD-style (see the file LICENSE)
-- 
-- Maintainer  :  ugeorge@kth.se
-- Stability   :  experimental
-- Portability :  portable
--
-- This is a small experimental library for modeling multi-clock rate SY systems in
-- the style of Lustre <ForSyDe-Atom.html#halbwachs91 [Halbwachs91]>. It is
-- implemented mainly on top of the "ForSyDe.Atom.MoC.SY" library, re-using it to the
-- full extent, and it represents Lustre language constructs as specific
-- patterns. Instead of developing and representing an inherent clock calculus like
-- Lustre, this library merely propagates "no-ops" as absent
-- (i.e. 'ForSyDe.Atom.ExB.Absent.Abst') events and utilises the algebra of
-- "ForSyDe.Atom.ExB" to model clock rates. 
--
-- Internally, a "ForSyDe.Atom.MoC.SY.Clocked" process constructor represents
-- implicitly a "ForSyDe.Atom.MoC.SY" MoC layer wrapping a "ForSyDe.Atom.ExB.Absent"
-- behavior extension layer. Under these asumptions the "ForSyDe.Atom.MoC.SY.Clocked"
-- models can be interpreted as follows:
--
-- * the host "ForSyDe.Atom.MoC.SY" processes operate at the basic clock rate. I.e. a
--   signal where all events are present is active in the basic time scale.
--
-- * the wrapped "ForSyDe.Atom.ExB" behaviors operate on and propagate absent/present
--   events based on the operating clock rate. 'ForSyDe.Atom.ExB.Absent.Abst' means
--   that an event "did not occur". Combining a present with an absent event in any
--   regular operation (see 'comb22') would violate the clock constraints of
--   well-formed systems (see <ForSyDe-Atom.html#halbwachs91 [Halbwachs91]>) and would
--   throw a runtime error.
--
-- * Although "ForSyDe.Atom.MoC.SY.Clocked" is hosted on "ForSyDe.Atom.MoC.SY", the
--   'ForSyDe.Atom.ExB.Absent.Abst' "value" has no true meaning in a pure SY reactive
--   system. Therefore to interface between these two SY domains should always be made
--   through a 'toDE'/'fromDE' interface. __OBS:__ these interfaces are still
--   experimental and higly unsafe especially when considering feedback loops.
---------------------------------------------------------------------
module ForSyDe.Atom.MoC.SY.Clocked (
  Signal,

  -- * Lustre constructs

  -- | These are process constructors which imitate the behavior of Lustre constructs
  -- according to our "ForSyDe.Atom.MoC.SY.Clocked" definition.
  pre, (->-), when, current,

  -- * Auxiliary constructs

  -- | These are utility process constructors used in combination with the main
  -- constructs.
  is, whenIs1, whenIs2, whenIs3,
  whenPres1, whenPres2, whenPres3,
  filter, fill,

  -- * Regular constructors

  -- | These are the regular process constructors defined as patterns in the
  -- "ForSyDe.Atom.MoC" module, but adapted for the absent-extended behaviors.  
  delay,

  comb11, comb12, comb13, comb14,
  comb21, comb22, comb23, comb24,
  comb31, comb32, comb33, comb34,
  comb41, comb42, comb43, comb44,

  stated11, stated12, stated13, 
  stated21, stated22, stated23, 
  stated31, stated32, stated33, 

  state11, state12, state13, 
  state21, state22, state23, 
  state31, state32, state33,
  
  moore11, moore12, moore13, 
  moore21, moore22, moore23, 
  moore31, moore32, moore33, 

  mealy11, mealy12, mealy13, 
  mealy21, mealy22, mealy23, 
  mealy31, mealy32, mealy33
  
  ) where

import qualified ForSyDe.Atom.ExB as B
import           ForSyDe.Atom.ExB.Absent (AbstExt(..))
import           ForSyDe.Atom.MoC.SY.Core hiding (Signal)
import qualified ForSyDe.Atom.MoC.SY.Lib as SY
import           ForSyDe.Atom.MoC.Stream
import           ForSyDe.Atom.Utility.Tuple
import           Prelude hiding (filter)

-- | Alias showing that in the "ForSyDe.Atom.MoC.SY.Clocked" domain, a signal is
-- considered a stream of absent-extended SY events.
type Signal a = Stream (SY (AbstExt a))

infixl 3 ->-

------- WHEN, FILTER, FILL, HOLD -------

-- | The @->@ operator in Lustre.
--
-- >>> let s1 = signal [Prst 1, Prst 2, Prst 3, Prst 4, Prst 5]
-- >>> unit (Prst 10) ->- s1
-- {10,2,3,4,5}
(->-) :: Signal a -> Signal a -> Signal a
a :: Signal a
a ->- :: Signal a -> Signal a -> Signal a
->- b :: Signal a
b = Signal a -> SY (AbstExt a)
forall a. Stream a -> a
headS Signal a
a SY (AbstExt a) -> Signal a -> Signal a
forall e. e -> Stream e -> Stream e
:- Signal a -> Signal a
forall e. Stream e -> Stream e
tailS Signal a
b

-- | The @pre@ construct in Lustre. __OBS:__ instead of /nil/, the first value is an
-- 'Abst'. /TODO:/ unclear if this breaks the SY assumption.
--
-- >>> let s1 = signal [Prst 1, Prst 2, Prst 3, Prst 4, Prst 5]
-- >>> pre s1
-- {⟂,1,2,3,4,5}
pre :: Signal a -> Signal a
pre :: Signal a -> Signal a
pre a :: Signal a
a = AbstExt a -> SY (AbstExt a)
forall a. a -> SY a
SY AbstExt a
forall a. AbstExt a
Abst SY (AbstExt a) -> Signal a -> Signal a
forall e. e -> Stream e -> Stream e
:- Signal a
a

-- | Determines the existence of events in the (left) signal based on the (right)
-- signal of boolean values (conditions). In Lustre this construct is used to generate
-- other clock rates.
--
-- >>> let s1   = (signal . map Prst) [1,2,3,4,5]
-- >>> let pred = signal [Prst False, Abst, Prst True, Prst False, Prst True]
-- >>> s1 `when` pred
-- {⟂,⟂,3,⟂,5}
when :: Signal a    -- ^ Input signal
     -> Signal Bool -- ^ Signal of predicates
     -> Signal a    -- ^ Output signal
when :: Signal a -> Signal Bool -> Signal a
when s :: Signal a
s p :: Signal Bool
p = (AbstExt Bool -> AbstExt a -> AbstExt a)
-> Signal Bool -> Signal a -> Signal a
forall a1 a2 b1.
(a1 -> a2 -> b1) -> Signal a1 -> Signal a2 -> Signal b1
SY.comb21 AbstExt Bool -> AbstExt a -> AbstExt a
forall (b :: * -> *) a. ExB b => b Bool -> b a -> b a
B.filter Signal Bool
p Signal a
s

-- | Holds the last non-absent value in a signal, like the @current@ construct in
-- Lustre. __OBS:__ instead of /nil/, the first value is user-defined.
--
-- >>> let s1   = signal [Abst, Abst, Prst 1, Prst 2, Abst, Prst 3]
-- >>> current 0 s1
-- {0,0,1,2,2,3}
current :: a
        -- ^ Value to fill with in case there was no previous value
        -> Signal a -- ^ Input
        -> Signal a -- ^ Output
current :: a -> Signal a -> Signal a
current i :: a
i = (a -> AbstExt a) -> Signal a -> Signal a
forall a1 b1. (a1 -> b1) -> Signal a1 -> Signal b1
SY.comb11 a -> AbstExt a
forall (b :: * -> *) a. ExB b => a -> b a
B.extend (Signal a -> Signal a)
-> (Signal a -> Signal a) -> Signal a -> Signal a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> AbstExt a -> a) -> a -> Signal a -> Signal a
forall b1 a1. (b1 -> a1 -> b1) -> b1 -> Signal a1 -> Signal b1
SY.state11 a -> AbstExt a -> a
forall (b :: * -> *) a. ExB b => a -> b a -> a
B.degen a
i

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

-- | Applies a predicate function on a signal of absent-extended events.
--
-- >>> let s1   = signal $ map Prst [1,2,3,4,5]
-- >>> s1 `is` (>3)
-- {False,False,False,True,True}
--
-- It is useful in combination with 'when'.
--
-- >>> let s1 = (signal . map Prst) [1,2,3,4,5]
-- >>> let s2 = (signal . map Prst) [11,22,33,44,55]
-- >>> s2 `when` (s1 `is` (>3))
-- {⟂,⟂,⟂,44,55}
is :: Signal a -> (a -> Bool) -> Signal Bool
is :: Signal a -> (a -> Bool) -> Signal Bool
is  s :: Signal a
s p :: a -> Bool
p = (AbstExt a -> AbstExt Bool) -> Signal a -> Signal Bool
forall a1 b1. (a1 -> b1) -> Signal a1 -> Signal b1
SY.comb11 ((a -> Bool) -> AbstExt a -> AbstExt Bool
forall (b :: * -> *) a a'. ExB b => (a -> a') -> b a -> b a'
B.res11 a -> Bool
p) Signal a
s


-- | Serializes 'when' with 'is' for up to three input signals.
--
-- Constructors @whenIs[1-3]@
--
-- >>> let s1 = (signal . map Prst) [1,2,3,4,5]
-- >>> let s2 = (signal . map Prst) [11,22,33,44,55]
-- >>> whenIs2 (>3) s1 s1 s2
-- ({⟂,⟂,⟂,4,5},{⟂,⟂,⟂,44,55})
whenIs2 :: (a -> Bool)
        -> Signal a
        -> Signal b1 -> Signal b2
        -> (Signal b1, Signal b2)
whenIs1 :: (a -> Bool) -> Signal a
        -> Signal b1 -> Signal b1
whenIs3 :: (a -> Bool) -> Signal a
        -> Signal b1 -> Signal b2 -> Signal b3
        -> (Signal b1, Signal b2, Signal b3)
        
whenIs1 :: (a -> Bool) -> Signal a -> Signal b1 -> Signal b1
whenIs1 p :: a -> Bool
p = (AbstExt a -> AbstExt b1 -> AbstExt b1)
-> Signal a -> Signal b1 -> Signal b1
forall a1 a2 b1.
(a1 -> a2 -> b1) -> Signal a1 -> Signal a2 -> Signal b1
SY.comb21 (\a :: AbstExt a
a b1 :: AbstExt b1
b1 -> AbstExt Bool -> AbstExt b1 -> AbstExt b1
forall (b :: * -> *) a. ExB b => b Bool -> b a -> b a
B.filter ((a -> Bool) -> AbstExt a -> AbstExt Bool
forall (b :: * -> *) a a'. ExB b => (a -> a') -> b a -> b a'
B.res11 a -> Bool
p AbstExt a
a) AbstExt b1
b1)
whenIs2 :: (a -> Bool)
-> Signal a -> Signal b1 -> Signal b2 -> (Signal b1, Signal b2)
whenIs2 p :: a -> Bool
p = (AbstExt a -> AbstExt b1 -> AbstExt b2 -> (AbstExt b1, AbstExt b2))
-> Signal a -> Signal b1 -> Signal b2 -> (Signal b1, Signal b2)
forall a1 a2 a3 b1 b2.
(a1 -> a2 -> a3 -> (b1, b2))
-> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2)
SY.comb32 AbstExt a -> AbstExt b1 -> AbstExt b2 -> (AbstExt b1, AbstExt b2)
forall (f :: * -> *) a1 b.
ExB f =>
f a -> f a1 -> f b -> (f a1, f b)
filterF
  where filterF :: f a -> f a1 -> f b -> (f a1, f b)
filterF a :: f a
a b1 :: f a1
b1 b2 :: f b
b2 
          = let tupd :: f (a1, b)
tupd = (a1 -> b -> (a1, b)) -> f a1 -> f b -> f (a1, b)
forall (b :: * -> *) a1 a2 a'.
ExB b =>
(a1 -> a2 -> a') -> b a1 -> b a2 -> b a'
B.res21 (,) f a1
b1 f b
b2
            in (f Bool -> f (a1, b) -> f (a1, b)
forall (b :: * -> *) a. ExB b => b Bool -> b a -> b a
B.filter ((a -> Bool) -> f a -> f Bool
forall (b :: * -> *) a a'. ExB b => (a -> a') -> b a -> b a'
B.res11 a -> Bool
p f a
a) f (a1, b)
tupd f (a1, b) -> (f a1, f b)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
whenIs3 :: (a -> Bool)
-> Signal a
-> Signal b1
-> Signal b2
-> Signal b3
-> (Signal b1, Signal b2, Signal b3)
whenIs3 p :: a -> Bool
p = (AbstExt a
 -> AbstExt b1
 -> AbstExt b2
 -> AbstExt b3
 -> (AbstExt b1, AbstExt b2, AbstExt b3))
-> Signal a
-> Signal b1
-> Signal b2
-> Signal b3
-> (Signal b1, Signal b2, Signal b3)
forall a1 a2 a3 a4 b1 b2 b3.
(a1 -> a2 -> a3 -> a4 -> (b1, b2, b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2, Signal b3)
SY.comb43 AbstExt a
-> AbstExt b1
-> AbstExt b2
-> AbstExt b3
-> (AbstExt b1, AbstExt b2, AbstExt b3)
forall (f :: * -> *) a b1 b2.
ExB f =>
f a -> f a -> f b1 -> f b2 -> (f a, f b1, f b2)
filterF
  where filterF :: f a -> f a -> f b1 -> f b2 -> (f a, f b1, f b2)
filterF a :: f a
a b1 :: f a
b1 b2 :: f b1
b2 b3 :: f b2
b3
          = let tupd :: f (a, b1, b2)
tupd = (a -> b1 -> b2 -> (a, b1, b2))
-> f a -> f b1 -> f b2 -> f (a, b1, b2)
forall (b :: * -> *) a1 a2 a3 a'.
ExB b =>
(a1 -> a2 -> a3 -> a') -> b a1 -> b a2 -> b a3 -> b a'
B.res31 (,,) f a
b1 f b1
b2 f b2
b3
            in (f Bool -> f (a, b1, b2) -> f (a, b1, b2)
forall (b :: * -> *) a. ExB b => b Bool -> b a -> b a
B.filter ((a -> Bool) -> f a -> f Bool
forall (b :: * -> *) a a'. ExB b => (a -> a') -> b a -> b a'
B.res11 a -> Bool
p f a
a) f (a, b1, b2)
tupd f (a, b1, b2) -> (f a, f b1, f b2)
forall (f :: * -> *) a b1 b2.
Functor f =>
f (a, b1, b2) -> (f a, f b1, f b2)
|<<)

-- | Same as 'whenIs2' but triggering the output events only based on the presence of
-- the first input rather than a boolean.
--
-- >>> let s1 = signal $ map Prst [1,2,3,4,5]
-- >>> let sp = signal [Prst 1, Prst 1, Abst, Prst 1, Abst]
-- >>> whenPres1 sp s1
-- {1,2,⟂,4,⟂}
whenPres2 :: Signal b -> Signal b1 -> Signal b2 -> (Signal b1, Signal b2)
whenPres2 = (b -> Bool)
-> Signal b -> Signal b1 -> Signal b2 -> (Signal b1, Signal b2)
forall a b1 b2.
(a -> Bool)
-> Signal a -> Signal b1 -> Signal b2 -> (Signal b1, Signal b2)
whenIs2 (Bool -> b -> Bool
forall a b. a -> b -> a
const Bool
True)
whenPres1 :: Signal b -> Signal b1 -> Signal b1
whenPres1 = (b -> Bool) -> Signal b -> Signal b1 -> Signal b1
forall a b1. (a -> Bool) -> Signal a -> Signal b1 -> Signal b1
whenIs1 (Bool -> b -> Bool
forall a b. a -> b -> a
const Bool
True)
whenPres3 :: Signal b
-> Signal b1
-> Signal b2
-> Signal b3
-> (Signal b1, Signal b2, Signal b3)
whenPres3 = (b -> Bool)
-> Signal b
-> Signal b1
-> Signal b2
-> Signal b3
-> (Signal b1, Signal b2, Signal b3)
forall a b1 b2 b3.
(a -> Bool)
-> Signal a
-> Signal b1
-> Signal b2
-> Signal b3
-> (Signal b1, Signal b2, Signal b3)
whenIs3 (Bool -> b -> Bool
forall a b. a -> b -> a
const Bool
True)


-- | Filters out values to 'Abst' if they do not fulfill a predicate function,
-- i.e. applies @whenIs1@ on itself.
--
-- >>> let s1   = (signal . map Prst) [1,2,3,4,5]
-- >>> filter (>3) s1
-- {⟂,⟂,⟂,4,5}
filter :: (a -> Bool) -- ^ Predicate function
       -> Signal a    -- ^ Input signal
       -> Signal a    -- ^ Output signal
filter :: (a -> Bool) -> Signal a -> Signal a
filter p :: a -> Bool
p s :: Signal a
s = (a -> Bool) -> Signal a -> Signal a -> Signal a
forall a b1. (a -> Bool) -> Signal a -> Signal b1 -> Signal b1
whenIs1 a -> Bool
p Signal a
s Signal a
s


-- | Fills absent events with a user-defined value.
--
-- >>> let s1   = signal [Abst, Abst, Prst 1, Prst 2, Abst, Prst 3]
-- >>> fill 0 s1
-- {0,0,1,2,0,3}
fill :: a        -- ^ Value to fill with
     -> Signal a -- ^ Input
     -> Signal a -- ^ Output
fill :: a -> Signal a -> Signal a
fill x :: a
x = (AbstExt a -> AbstExt a) -> Signal a -> Signal a
forall a1 b1. (a1 -> b1) -> Signal a1 -> Signal b1
SY.comb11 (a -> AbstExt a
forall (b :: * -> *) a. ExB b => a -> b a
B.extend (a -> AbstExt a) -> (AbstExt a -> a) -> AbstExt a -> AbstExt a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> AbstExt a -> a
forall (b :: * -> *) a. ExB b => a -> b a -> a
B.degen a
x)


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

-- | The @delay@ process "delays" a signal with one event. Serializes a 'pre' and a
-- '->-'.
--
-- >>> let s = signal [Prst 1,Prst 2,Prst 3,Abst,Prst 5]
-- >>> delay 0 s
-- {0,1,2,3,⟂,5}
delay :: a         -- ^ initial value
      -> Signal a  -- ^ input signal
      -> Signal a  -- ^ output signal
delay :: a -> Signal a -> Signal a
delay = AbstExt a -> Signal a -> Signal a
forall a. a -> Signal a -> Signal a
SY.delay (AbstExt a -> Signal a -> Signal a)
-> (a -> AbstExt a) -> a -> Signal a -> Signal a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> AbstExt a
forall a. a -> AbstExt a
Prst

-- | @comb@ processes map combinatorial functions on signals on synchronized input
-- signals. It implements the @comb@ pattern (see 'ForSyDe.Atom.MoC.comb22'), and
-- implicitly applies a resolution between absent-extended events (see
-- 'ForSyDe.Atom.ExB.res22')
-- 
-- Constructors: @comb[1-4][1-4]@.
--
-- >>> let s1 = (signal . map Prst) [1..]
-- >>> let s2 = signal [Prst 1,Prst 1,Abst,Prst 1,Prst 1]
-- >>>  comb11 (+1) s2
-- {2,2,⟂,2,2}
-- >>> comb22 (\a b-> (a+b,a-b)) s2 s2
-- ({2,2,⟂,2,2},{0,0,⟂,0,0})
--
-- Combining two signals at different clock rates throws a runtime error:
--
-- > comb22 (\a b-> (a+b,a-b)) s1 s2
-- > ({2,3,*** Exception: [ExB.Absent] Illegal occurrence of an absent and present event
comb22 :: (a1 -> a2 -> (b1, b2)) -- ^ function on values
       -> Signal a1              -- ^ first input signal
       -> Signal a2              -- ^ second input signal
       -> (Signal b1, Signal b2) -- ^ two output signals
comb11 :: (a1 -> b1)
       -> Signal a1 -> Signal b1
comb12 :: (a1 -> (b1, b2))
       -> Signal a1 -> (Signal b1, Signal b2)
comb13 :: (a1 -> (b1, b2, b3))
       -> Signal a1 -> (Signal b1, Signal b2, Signal b3)
comb14 :: (a1 -> (b1, b2, b3, b4))
       -> Signal a1 -> (Signal b1, Signal b2, Signal b3, Signal b4)
comb21 :: (a1 -> a2 -> b1)
       -> Signal a1 -> Signal a2 -> Signal b1
comb23 :: (a1 -> a2 -> (b1, b2, b3))
       -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3)
comb24 :: (a1 -> a2 -> (b1, b2, b3, b4))
       -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3, Signal b4)
comb31 :: (a1 -> a2 -> a3 -> b1)
       -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
comb32 :: (a1 -> a2 -> a3 -> (b1, b2))
       -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2)
comb33 :: (a1 -> a2 -> a3 -> (b1, b2, b3))
       -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2, Signal b3)
comb34 :: (a1 -> a2 -> a3 -> (b1, b2, b3, b4))
       -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2, Signal b3, Signal b4)
comb41 :: (a1 -> a2 -> a3 -> a4 -> b1)
       -> Signal a1 -> Signal a2 -> Signal a3 -> Signal a4 -> Signal b1
comb42 :: (a1 -> a2 -> a3 -> a4 -> (b1, b2))
       -> Signal a1 -> Signal a2 -> Signal a3 -> Signal a4 -> (Signal b1, Signal b2)
comb43 :: (a1 -> a2 -> a3 -> a4 -> (b1, b2, b3))
       -> Signal a1 -> Signal a2 -> Signal a3 -> Signal a4 -> (Signal b1, Signal b2, Signal b3)
comb44 :: (a1 -> a2 -> a3 -> a4 -> (b1, b2, b3, b4))
       -> Signal a1 -> Signal a2 -> Signal a3 -> Signal a4 -> (Signal b1, Signal b2, Signal b3, Signal b4)

comb11 :: (a1 -> b1) -> Signal a1 -> Signal b1
comb11 = (AbstExt a1 -> AbstExt b1) -> Signal a1 -> Signal b1
forall a1 b1. (a1 -> b1) -> Signal a1 -> Signal b1
SY.comb11 ((AbstExt a1 -> AbstExt b1) -> Signal a1 -> Signal b1)
-> ((a1 -> b1) -> AbstExt a1 -> AbstExt b1)
-> (a1 -> b1)
-> Signal a1
-> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> b1) -> AbstExt a1 -> AbstExt b1
forall (b :: * -> *) a a'. ExB b => (a -> a') -> b a -> b a'
B.res11 
comb12 :: (a1 -> (b1, b2)) -> Signal a1 -> (Signal b1, Signal b2)
comb12 = (AbstExt a1 -> (AbstExt b1, AbstExt b2))
-> Signal a1 -> (Signal b1, Signal b2)
forall a1 b1 b2.
(a1 -> (b1, b2)) -> Signal a1 -> (Signal b1, Signal b2)
SY.comb12 ((AbstExt a1 -> (AbstExt b1, AbstExt b2))
 -> Signal a1 -> (Signal b1, Signal b2))
-> ((a1 -> (b1, b2)) -> AbstExt a1 -> (AbstExt b1, AbstExt b2))
-> (a1 -> (b1, b2))
-> Signal a1
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> (b1, b2)) -> AbstExt a1 -> (AbstExt b1, AbstExt b2)
forall (f :: * -> *) a a1 b.
ExB f =>
(a -> (a1, b)) -> f a -> (f a1, f b)
B.res12 
comb13 :: (a1 -> (b1, b2, b3))
-> Signal a1 -> (Signal b1, Signal b2, Signal b3)
comb13 = (AbstExt a1 -> (AbstExt b1, AbstExt b2, AbstExt b3))
-> Signal a1 -> (Signal b1, Signal b2, Signal b3)
forall a1 b1 b2 b3.
(a1 -> (b1, b2, b3))
-> Signal a1 -> (Signal b1, Signal b2, Signal b3)
SY.comb13 ((AbstExt a1 -> (AbstExt b1, AbstExt b2, AbstExt b3))
 -> Signal a1 -> (Signal b1, Signal b2, Signal b3))
-> ((a1 -> (b1, b2, b3))
    -> AbstExt a1 -> (AbstExt b1, AbstExt b2, AbstExt b3))
-> (a1 -> (b1, b2, b3))
-> Signal a1
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> (b1, b2, b3))
-> AbstExt a1 -> (AbstExt b1, AbstExt b2, AbstExt b3)
forall (f :: * -> *) a1 a2 b1 b2.
ExB f =>
(a1 -> (a2, b1, b2)) -> f a1 -> (f a2, f b1, f b2)
B.res13 
comb14 :: (a1 -> (b1, b2, b3, b4))
-> Signal a1 -> (Signal b1, Signal b2, Signal b3, Signal b4)
comb14 = (AbstExt a1 -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
-> Signal a1 -> (Signal b1, Signal b2, Signal b3, Signal b4)
forall a1 b1 b2 b3 b4.
(a1 -> (b1, b2, b3, b4))
-> Signal a1 -> (Signal b1, Signal b2, Signal b3, Signal b4)
SY.comb14 ((AbstExt a1 -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
 -> Signal a1 -> (Signal b1, Signal b2, Signal b3, Signal b4))
-> ((a1 -> (b1, b2, b3, b4))
    -> AbstExt a1 -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
-> (a1 -> (b1, b2, b3, b4))
-> Signal a1
-> (Signal b1, Signal b2, Signal b3, Signal b4)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> (b1, b2, b3, b4))
-> AbstExt a1 -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4)
forall (f :: * -> *) a1 a2 b1 c b2.
ExB f =>
(a1 -> (a2, b1, c, b2)) -> f a1 -> (f a2, f b1, f c, f b2)
B.res14
comb21 :: (a1 -> a2 -> b1) -> Signal a1 -> Signal a2 -> Signal b1
comb21 = (AbstExt a1 -> AbstExt a2 -> AbstExt b1)
-> Signal a1 -> Signal a2 -> Signal b1
forall a1 a2 b1.
(a1 -> a2 -> b1) -> Signal a1 -> Signal a2 -> Signal b1
SY.comb21 ((AbstExt a1 -> AbstExt a2 -> AbstExt b1)
 -> Signal a1 -> Signal a2 -> Signal b1)
-> ((a1 -> a2 -> b1) -> AbstExt a1 -> AbstExt a2 -> AbstExt b1)
-> (a1 -> a2 -> b1)
-> Signal a1
-> Signal a2
-> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> b1) -> AbstExt a1 -> AbstExt a2 -> AbstExt b1
forall (b :: * -> *) a1 a2 a'.
ExB b =>
(a1 -> a2 -> a') -> b a1 -> b a2 -> b a'
B.res21
comb22 :: (a1 -> a2 -> (b1, b2))
-> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
comb22 = (AbstExt a1 -> AbstExt a2 -> (AbstExt b1, AbstExt b2))
-> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
forall a1 a2 b1 b2.
(a1 -> a2 -> (b1, b2))
-> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
SY.comb22 ((AbstExt a1 -> AbstExt a2 -> (AbstExt b1, AbstExt b2))
 -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2))
-> ((a1 -> a2 -> (b1, b2))
    -> AbstExt a1 -> AbstExt a2 -> (AbstExt b1, AbstExt b2))
-> (a1 -> a2 -> (b1, b2))
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> (b1, b2))
-> AbstExt a1 -> AbstExt a2 -> (AbstExt b1, AbstExt b2)
forall (b :: * -> *) a1 a2 a1' a2'.
ExB b =>
(a1 -> a2 -> (a1', a2')) -> b a1 -> b a2 -> (b a1', b a2')
B.res22
comb23 :: (a1 -> a2 -> (b1, b2, b3))
-> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3)
comb23 = (AbstExt a1 -> AbstExt a2 -> (AbstExt b1, AbstExt b2, AbstExt b3))
-> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3)
forall a1 a2 b1 b2 b3.
(a1 -> a2 -> (b1, b2, b3))
-> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3)
SY.comb23 ((AbstExt a1 -> AbstExt a2 -> (AbstExt b1, AbstExt b2, AbstExt b3))
 -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3))
-> ((a1 -> a2 -> (b1, b2, b3))
    -> AbstExt a1
    -> AbstExt a2
    -> (AbstExt b1, AbstExt b2, AbstExt b3))
-> (a1 -> a2 -> (b1, b2, b3))
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> (b1, b2, b3))
-> AbstExt a1 -> AbstExt a2 -> (AbstExt b1, AbstExt b2, AbstExt b3)
forall (f :: * -> *) a1 a2 a3 b1 b2.
ExB f =>
(a1 -> a2 -> (a3, b1, b2)) -> f a1 -> f a2 -> (f a3, f b1, f b2)
B.res23
comb24 :: (a1 -> a2 -> (b1, b2, b3, b4))
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3, Signal b4)
comb24 = (AbstExt a1
 -> AbstExt a2 -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3, Signal b4)
forall a1 a2 b1 b2 b3 b4.
(a1 -> a2 -> (b1, b2, b3, b4))
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3, Signal b4)
SY.comb24 ((AbstExt a1
  -> AbstExt a2 -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
 -> Signal a1
 -> Signal a2
 -> (Signal b1, Signal b2, Signal b3, Signal b4))
-> ((a1 -> a2 -> (b1, b2, b3, b4))
    -> AbstExt a1
    -> AbstExt a2
    -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
-> (a1 -> a2 -> (b1, b2, b3, b4))
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3, Signal b4)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> (b1, b2, b3, b4))
-> AbstExt a1
-> AbstExt a2
-> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4)
forall (f :: * -> *) a1 a2 a3 b1 c b2.
ExB f =>
(a1 -> a2 -> (a3, b1, c, b2))
-> f a1 -> f a2 -> (f a3, f b1, f c, f b2)
B.res24
comb31 :: (a1 -> a2 -> a3 -> b1)
-> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
comb31 = (AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> AbstExt b1)
-> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
forall a1 a2 a3 b1.
(a1 -> a2 -> a3 -> b1)
-> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
SY.comb31 ((AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> AbstExt b1)
 -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1)
-> ((a1 -> a2 -> a3 -> b1)
    -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> AbstExt b1)
-> (a1 -> a2 -> a3 -> b1)
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> a3 -> b1)
-> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> AbstExt b1
forall (b :: * -> *) a1 a2 a3 a'.
ExB b =>
(a1 -> a2 -> a3 -> a') -> b a1 -> b a2 -> b a3 -> b a'
B.res31
comb32 :: (a1 -> a2 -> a3 -> (b1, b2))
-> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2)
comb32 = (AbstExt a1
 -> AbstExt a2 -> AbstExt a3 -> (AbstExt b1, AbstExt b2))
-> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2)
forall a1 a2 a3 b1 b2.
(a1 -> a2 -> a3 -> (b1, b2))
-> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2)
SY.comb32 ((AbstExt a1
  -> AbstExt a2 -> AbstExt a3 -> (AbstExt b1, AbstExt b2))
 -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2))
-> ((a1 -> a2 -> a3 -> (b1, b2))
    -> AbstExt a1
    -> AbstExt a2
    -> AbstExt a3
    -> (AbstExt b1, AbstExt b2))
-> (a1 -> a2 -> a3 -> (b1, b2))
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> a3 -> (b1, b2))
-> AbstExt a1
-> AbstExt a2
-> AbstExt a3
-> (AbstExt b1, AbstExt b2)
forall (f :: * -> *) a1 a2 a3 a4 b.
ExB f =>
(a1 -> a2 -> a3 -> (a4, b)) -> f a1 -> f a2 -> f a3 -> (f a4, f b)
B.res32
comb33 :: (a1 -> a2 -> a3 -> (b1, b2, b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
comb33 = (AbstExt a1
 -> AbstExt a2
 -> AbstExt a3
 -> (AbstExt b1, AbstExt b2, AbstExt b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
forall a1 a2 a3 b1 b2 b3.
(a1 -> a2 -> a3 -> (b1, b2, b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
SY.comb33 ((AbstExt a1
  -> AbstExt a2
  -> AbstExt a3
  -> (AbstExt b1, AbstExt b2, AbstExt b3))
 -> Signal a1
 -> Signal a2
 -> Signal a3
 -> (Signal b1, Signal b2, Signal b3))
-> ((a1 -> a2 -> a3 -> (b1, b2, b3))
    -> AbstExt a1
    -> AbstExt a2
    -> AbstExt a3
    -> (AbstExt b1, AbstExt b2, AbstExt b3))
-> (a1 -> a2 -> a3 -> (b1, b2, b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> a3 -> (b1, b2, b3))
-> AbstExt a1
-> AbstExt a2
-> AbstExt a3
-> (AbstExt b1, AbstExt b2, AbstExt b3)
forall (f :: * -> *) a1 a2 a3 a4 b1 b2.
ExB f =>
(a1 -> a2 -> a3 -> (a4, b1, b2))
-> f a1 -> f a2 -> f a3 -> (f a4, f b1, f b2)
B.res33
comb34 :: (a1 -> a2 -> a3 -> (b1, b2, b3, b4))
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3, Signal b4)
comb34 = (AbstExt a1
 -> AbstExt a2
 -> AbstExt a3
 -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3, Signal b4)
forall a1 a2 a3 b1 b2 b3 b4.
(a1 -> a2 -> a3 -> (b1, b2, b3, b4))
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3, Signal b4)
SY.comb34 ((AbstExt a1
  -> AbstExt a2
  -> AbstExt a3
  -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
 -> Signal a1
 -> Signal a2
 -> Signal a3
 -> (Signal b1, Signal b2, Signal b3, Signal b4))
-> ((a1 -> a2 -> a3 -> (b1, b2, b3, b4))
    -> AbstExt a1
    -> AbstExt a2
    -> AbstExt a3
    -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
-> (a1 -> a2 -> a3 -> (b1, b2, b3, b4))
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3, Signal b4)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> a3 -> (b1, b2, b3, b4))
-> AbstExt a1
-> AbstExt a2
-> AbstExt a3
-> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4)
forall (f :: * -> *) a1 a2 a3 a4 b1 c b2.
ExB f =>
(a1 -> a2 -> a3 -> (a4, b1, c, b2))
-> f a1 -> f a2 -> f a3 -> (f a4, f b1, f c, f b2)
B.res34
comb41 :: (a1 -> a2 -> a3 -> a4 -> b1)
-> Signal a1 -> Signal a2 -> Signal a3 -> Signal a4 -> Signal b1
comb41 = (AbstExt a1
 -> AbstExt a2 -> AbstExt a3 -> AbstExt a4 -> AbstExt b1)
-> Signal a1 -> Signal a2 -> Signal a3 -> Signal a4 -> Signal b1
forall a1 a2 a3 a4 b1.
(a1 -> a2 -> a3 -> a4 -> b1)
-> Signal a1 -> Signal a2 -> Signal a3 -> Signal a4 -> Signal b1
SY.comb41 ((AbstExt a1
  -> AbstExt a2 -> AbstExt a3 -> AbstExt a4 -> AbstExt b1)
 -> Signal a1 -> Signal a2 -> Signal a3 -> Signal a4 -> Signal b1)
-> ((a1 -> a2 -> a3 -> a4 -> b1)
    -> AbstExt a1
    -> AbstExt a2
    -> AbstExt a3
    -> AbstExt a4
    -> AbstExt b1)
-> (a1 -> a2 -> a3 -> a4 -> b1)
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> a3 -> a4 -> b1)
-> AbstExt a1
-> AbstExt a2
-> AbstExt a3
-> AbstExt a4
-> AbstExt b1
forall (b :: * -> *) a1 a2 a3 a4 a'.
ExB b =>
(a1 -> a2 -> a3 -> a4 -> a')
-> b a1 -> b a2 -> b a3 -> b a4 -> b a'
B.res41
comb42 :: (a1 -> a2 -> a3 -> a4 -> (b1, b2))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2)
comb42 = (AbstExt a1
 -> AbstExt a2
 -> AbstExt a3
 -> AbstExt a4
 -> (AbstExt b1, AbstExt b2))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2)
forall a1 a2 a3 a4 b1 b2.
(a1 -> a2 -> a3 -> a4 -> (b1, b2))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2)
SY.comb42 ((AbstExt a1
  -> AbstExt a2
  -> AbstExt a3
  -> AbstExt a4
  -> (AbstExt b1, AbstExt b2))
 -> Signal a1
 -> Signal a2
 -> Signal a3
 -> Signal a4
 -> (Signal b1, Signal b2))
-> ((a1 -> a2 -> a3 -> a4 -> (b1, b2))
    -> AbstExt a1
    -> AbstExt a2
    -> AbstExt a3
    -> AbstExt a4
    -> (AbstExt b1, AbstExt b2))
-> (a1 -> a2 -> a3 -> a4 -> (b1, b2))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> a3 -> a4 -> (b1, b2))
-> AbstExt a1
-> AbstExt a2
-> AbstExt a3
-> AbstExt a4
-> (AbstExt b1, AbstExt b2)
forall (f :: * -> *) a1 a2 a3 a4 a5 b.
ExB f =>
(a1 -> a2 -> a3 -> a4 -> (a5, b))
-> f a1 -> f a2 -> f a3 -> f a4 -> (f a5, f b)
B.res42
comb43 :: (a1 -> a2 -> a3 -> a4 -> (b1, b2, b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2, Signal b3)
comb43 = (AbstExt a1
 -> AbstExt a2
 -> AbstExt a3
 -> AbstExt a4
 -> (AbstExt b1, AbstExt b2, AbstExt b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2, Signal b3)
forall a1 a2 a3 a4 b1 b2 b3.
(a1 -> a2 -> a3 -> a4 -> (b1, b2, b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2, Signal b3)
SY.comb43 ((AbstExt a1
  -> AbstExt a2
  -> AbstExt a3
  -> AbstExt a4
  -> (AbstExt b1, AbstExt b2, AbstExt b3))
 -> Signal a1
 -> Signal a2
 -> Signal a3
 -> Signal a4
 -> (Signal b1, Signal b2, Signal b3))
-> ((a1 -> a2 -> a3 -> a4 -> (b1, b2, b3))
    -> AbstExt a1
    -> AbstExt a2
    -> AbstExt a3
    -> AbstExt a4
    -> (AbstExt b1, AbstExt b2, AbstExt b3))
-> (a1 -> a2 -> a3 -> a4 -> (b1, b2, b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> a3 -> a4 -> (b1, b2, b3))
-> AbstExt a1
-> AbstExt a2
-> AbstExt a3
-> AbstExt a4
-> (AbstExt b1, AbstExt b2, AbstExt b3)
forall (f :: * -> *) a1 a2 a3 a4 a5 b1 b2.
ExB f =>
(a1 -> a2 -> a3 -> a4 -> (a5, b1, b2))
-> f a1 -> f a2 -> f a3 -> f a4 -> (f a5, f b1, f b2)
B.res43
comb44 :: (a1 -> a2 -> a3 -> a4 -> (b1, b2, b3, b4))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2, Signal b3, Signal b4)
comb44 = (AbstExt a1
 -> AbstExt a2
 -> AbstExt a3
 -> AbstExt a4
 -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2, Signal b3, Signal b4)
forall a1 a2 a3 a4 b1 b2 b3 b4.
(a1 -> a2 -> a3 -> a4 -> (b1, b2, b3, b4))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2, Signal b3, Signal b4)
SY.comb44 ((AbstExt a1
  -> AbstExt a2
  -> AbstExt a3
  -> AbstExt a4
  -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
 -> Signal a1
 -> Signal a2
 -> Signal a3
 -> Signal a4
 -> (Signal b1, Signal b2, Signal b3, Signal b4))
-> ((a1 -> a2 -> a3 -> a4 -> (b1, b2, b3, b4))
    -> AbstExt a1
    -> AbstExt a2
    -> AbstExt a3
    -> AbstExt a4
    -> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4))
-> (a1 -> a2 -> a3 -> a4 -> (b1, b2, b3, b4))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2, Signal b3, Signal b4)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a1 -> a2 -> a3 -> a4 -> (b1, b2, b3, b4))
-> AbstExt a1
-> AbstExt a2
-> AbstExt a3
-> AbstExt a4
-> (AbstExt b1, AbstExt b2, AbstExt b3, AbstExt b4)
forall (f :: * -> *) a1 a2 a3 a4 a5 b1 c b2.
ExB f =>
(a1 -> a2 -> a3 -> a4 -> (a5, b1, c, b2))
-> f a1 -> f a2 -> f a3 -> f a4 -> (f a5, f b1, f c, f b2)
B.res44

-- internal: reconstructs a degenerated signal based on an observation signal
react1 :: Signal b -> Signal b1 -> Signal b1
react1 rs :: Signal b
rs = Signal b -> Signal b1 -> Signal b1
forall b b1. Signal b -> Signal b1 -> Signal b1
whenPres1 Signal b
rs (Signal b1 -> Signal b1)
-> (Signal b1 -> Signal b1) -> Signal b1 -> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> AbstExt b1) -> Signal b1 -> Signal b1
forall a1 b1. (a1 -> b1) -> Signal a1 -> Signal b1
SY.comb11 b1 -> AbstExt b1
forall (b :: * -> *) a. ExB b => a -> b a
B.extend
react2 :: Signal b -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
react2 rs :: Signal b
rs = (Signal b1 -> Signal b2 -> (Signal b1, Signal b2))
-> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall a1 a2 b1. (a1 -> a2 -> b1) -> (a1, a2) -> b1
(><) (Signal b -> Signal b1 -> Signal b2 -> (Signal b1, Signal b2)
forall b b1 b2.
Signal b -> Signal b1 -> Signal b2 -> (Signal b1, Signal b2)
whenPres2 Signal b
rs) ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> (Signal b1, Signal b2)
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Signal b1 -> Signal b1, Signal b2 -> Signal b2)
-> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall a1 b1 a2 b2. (a1 -> b1, a2 -> b2) -> (a1, a2) -> (b1, b2)
($$) (Signal b1 -> Signal b1
forall a. Signal a -> Signal (AbstExt a)
ext,Signal b2 -> Signal b2
forall a. Signal a -> Signal (AbstExt a)
ext)
  where ext :: Signal a -> Signal (AbstExt a)
ext = (a -> AbstExt a) -> Signal a -> Signal (AbstExt a)
forall a1 b1. (a1 -> b1) -> Signal a1 -> Signal b1
SY.comb11 a -> AbstExt a
forall (b :: * -> *) a. ExB b => a -> b a
B.extend
react3 :: Signal b
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
react3 rs :: Signal b
rs = (Signal b1
 -> Signal b2 -> Signal b3 -> (Signal b1, Signal b2, Signal b3))
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall t1 t2 t3 t4. (t1 -> t2 -> t3 -> t4) -> (t1, t2, t3) -> t4
(><<) (Signal b
-> Signal b1
-> Signal b2
-> Signal b3
-> (Signal b1, Signal b2, Signal b3)
forall b b1 b2 b3.
Signal b
-> Signal b1
-> Signal b2
-> Signal b3
-> (Signal b1, Signal b2, Signal b3)
whenPres3 Signal b
rs) ((Signal b1, Signal b2, Signal b3)
 -> (Signal b1, Signal b2, Signal b3))
-> ((Signal b1, Signal b2, Signal b3)
    -> (Signal b1, Signal b2, Signal b3))
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Signal b1 -> Signal b1, Signal b2 -> Signal b2,
 Signal b3 -> Signal b3)
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall t1 a t2 b t3 c.
(t1 -> a, t2 -> b, t3 -> c) -> (t1, t2, t3) -> (a, b, c)
($$$) (Signal b1 -> Signal b1
forall a. Signal a -> Signal (AbstExt a)
ext,Signal b2 -> Signal b2
forall a. Signal a -> Signal (AbstExt a)
ext,Signal b3 -> Signal b3
forall a. Signal a -> Signal (AbstExt a)
ext)
  where ext :: Signal a -> Signal (AbstExt a)
ext = (a -> AbstExt a) -> Signal a -> Signal (AbstExt a)
forall a1 b1. (a1 -> b1) -> Signal a1 -> Signal b1
SY.comb11 a -> AbstExt a
forall (b :: * -> *) a. ExB b => a -> b a
B.extend
  
-- | @state@ is a state machine without an output decoder, that reacts
-- instantaneously. It implements the @state@ pattern (see
-- 'ForSyDe.Atom.MoC.state22'), and operates on 'ForSyDe.Atom.ExB.degen'erated
-- absent-extended values (see 'ForSyDe.Atom.ExB.ignore22') in order to propagate
-- absent events properly and not raise absent-present resolution errors.
--
-- Constructors: @state[1-3][1-3]@.
--
-- >>> let ones = takeS 8 $ SY.constant1 (Prst 1)
-- >>> let b = (signal . map Prst) [False,True,False,False,True,True,False,True]
-- >>> ones
-- {1,1,1,1,1,1,1,1}
-- >>> b
-- {False,True,False,False,True,True,False,True}
-- >>> state11 (+) 1 ones
-- {2,3,4,5,6,7,8,9}
-- >>> state11 (+) 1 (ones `when` b)
-- {⟂,2,⟂,⟂,3,4,⟂,5}
-- >>> state11 (+) 1 ones `when` b
-- {⟂,3,⟂,⟂,6,7,⟂,9}
state22 :: (b1 -> b2 -> a1 -> a2 -> (b1, b2))
           -- ^ next state function
           -> (b1, b2)
           -- ^ initial state values
           -> Signal a1
           -- ^ first input signal
           -> Signal a2
           -- ^ second input signal
           -> (Signal b1, Signal b2) -- ^ output signals
state11 :: (b1 -> a1 -> b1) -> b1
        -> Signal a1 -> Signal b1
state12 :: (b1 -> b2 -> a1 -> (b1, b2)) -> (b1, b2)
        -> Signal a1 -> (Signal b1, Signal b2)
state13 :: (b1 -> b2 -> b3 -> a1 -> (b1, b2, b3)) -> (b1, b2, b3)
        -> Signal a1 -> (Signal b1, Signal b2, Signal b3)
state21 :: (b1 -> a1 -> a2 -> b1) -> b1
        -> Signal a1 -> Signal a2 -> Signal b1
state23 :: (b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3)) -> (b1, b2, b3)
        -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3)
state31 :: (b1 -> a1 -> a2 -> a3 -> b1) -> b1
        -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
state32 :: (b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2)) -> (b1, b2)
        -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2)
state33 :: (b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3)) -> (b1, b2, b3)
        -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2, Signal b3)

state11 :: (b1 -> a1 -> b1) -> b1 -> Signal a1 -> Signal b1
state11 ns :: b1 -> a1 -> b1
ns i :: b1
i s1 :: Signal a1
s1 = Signal a1 -> Signal b1 -> Signal b1
forall b b1. Signal b -> Signal b1 -> Signal b1
react1 Signal a1
s1 (Signal b1 -> Signal b1) -> Signal b1 -> Signal b1
forall a b. (a -> b) -> a -> b
$ (b1 -> AbstExt a1 -> b1) -> b1 -> Signal a1 -> Signal b1
forall b1 a1. (b1 -> a1 -> b1) -> b1 -> Signal a1 -> Signal b1
SY.state11 ((b1 -> a1 -> b1) -> b1 -> AbstExt a1 -> b1
forall (b :: * -> *) t a. ExB b => (t -> a -> t) -> t -> b a -> t
B.ignore11 b1 -> a1 -> b1
ns) b1
i Signal a1
s1
state12 :: (b1 -> b2 -> a1 -> (b1, b2))
-> (b1, b2) -> Signal a1 -> (Signal b1, Signal b2)
state12 ns :: b1 -> b2 -> a1 -> (b1, b2)
ns i :: (b1, b2)
i s1 :: Signal a1
s1 = Signal a1 -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall b b1 b2.
Signal b -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
react2 Signal a1
s1 ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall a b. (a -> b) -> a -> b
$ (b1 -> b2 -> AbstExt 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)
SY.state12 ((b1 -> b2 -> a1 -> (b1, b2)) -> b1 -> b2 -> AbstExt a1 -> (b1, b2)
forall (b :: * -> *) t1 t2 a.
ExB b =>
(t1 -> t2 -> a -> (t1, t2)) -> t1 -> t2 -> b a -> (t1, t2)
B.ignore12 b1 -> b2 -> a1 -> (b1, b2)
ns) (b1, b2)
i Signal a1
s1
state13 :: (b1 -> b2 -> b3 -> a1 -> (b1, b2, b3))
-> (b1, b2, b3) -> Signal a1 -> (Signal b1, Signal b2, Signal b3)
state13 ns :: b1 -> b2 -> b3 -> a1 -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: Signal a1
s1 = Signal a1
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall b b1 b2 b3.
Signal b
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
react3 Signal a1
s1 ((Signal b1, Signal b2, Signal b3)
 -> (Signal b1, Signal b2, Signal b3))
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall a b. (a -> b) -> a -> b
$ (b1 -> b2 -> b3 -> AbstExt 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)
SY.state13 ((b1 -> b2 -> b3 -> a1 -> (b1, b2, b3))
-> b1 -> b2 -> b3 -> AbstExt a1 -> (b1, b2, b3)
forall (b :: * -> *) t1 t2 t3 a.
ExB b =>
(t1 -> t2 -> t3 -> a -> (t1, t2, t3))
-> t1 -> t2 -> t3 -> b a -> (t1, t2, t3)
B.ignore13 b1 -> b2 -> b3 -> a1 -> (b1, b2, b3)
ns) (b1, b2, b3)
i Signal a1
s1
state21 :: (b1 -> a1 -> a2 -> b1) -> b1 -> Signal a1 -> Signal a2 -> Signal b1
state21 ns :: b1 -> a1 -> a2 -> b1
ns i :: b1
i s1 :: Signal a1
s1 = (Signal a1 -> Signal b1 -> Signal b1
forall b b1. Signal b -> Signal b1 -> Signal b1
react1 Signal a1
s1 (Signal b1 -> Signal b1)
-> (Signal a2 -> Signal b1) -> Signal a2 -> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> AbstExt a1 -> AbstExt a2 -> b1)
-> b1 -> Signal a1 -> Signal a2 -> Signal b1
forall b1 a1 a2.
(b1 -> a1 -> a2 -> b1) -> b1 -> Signal a1 -> Signal a2 -> Signal b1
SY.state21 ((b1 -> a1 -> a2 -> b1) -> b1 -> AbstExt a1 -> AbstExt a2 -> b1
forall (b :: * -> *) t a1 a2.
ExB b =>
(t -> a1 -> a2 -> t) -> t -> b a1 -> b a2 -> t
B.ignore21 b1 -> a1 -> a2 -> b1
ns) b1
i Signal a1
s1)
state22 :: (b1 -> b2 -> a1 -> a2 -> (b1, b2))
-> (b1, b2) -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
state22 ns :: b1 -> b2 -> a1 -> a2 -> (b1, b2)
ns i :: (b1, b2)
i s1 :: Signal a1
s1 = (Signal a1 -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall b b1 b2.
Signal b -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
react2 Signal a1
s1 ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> (Signal a2 -> (Signal b1, Signal b2))
-> Signal a2
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> b2 -> AbstExt a1 -> AbstExt 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)
SY.state22 ((b1 -> b2 -> a1 -> a2 -> (b1, b2))
-> b1 -> b2 -> AbstExt a1 -> AbstExt a2 -> (b1, b2)
forall (b :: * -> *) a1 a2 a1' a2'.
ExB b =>
(a1 -> a2 -> a1' -> a2' -> (a1, a2))
-> a1 -> a2 -> b a1' -> b a2' -> (a1, a2)
B.ignore22 b1 -> b2 -> a1 -> a2 -> (b1, b2)
ns) (b1, b2)
i Signal a1
s1)
state23 :: (b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
state23 ns :: b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: Signal a1
s1 = (Signal a1
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall b b1 b2 b3.
Signal b
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
react3 Signal a1
s1 ((Signal b1, Signal b2, Signal b3)
 -> (Signal b1, Signal b2, Signal b3))
-> (Signal a2 -> (Signal b1, Signal b2, Signal b3))
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> b2 -> b3 -> AbstExt a1 -> AbstExt 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)
SY.state23 ((b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3))
-> b1 -> b2 -> b3 -> AbstExt a1 -> AbstExt a2 -> (b1, b2, b3)
forall (b :: * -> *) t1 t2 t3 a1 a2.
ExB b =>
(t1 -> t2 -> t3 -> a1 -> a2 -> (t1, t2, t3))
-> t1 -> t2 -> t3 -> b a1 -> b a2 -> (t1, t2, t3)
B.ignore23 b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3)
ns) (b1, b2, b3)
i Signal a1
s1)
state31 :: (b1 -> a1 -> a2 -> a3 -> b1)
-> b1 -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
state31 ns :: b1 -> a1 -> a2 -> a3 -> b1
ns i :: b1
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 = (Signal a1 -> Signal b1 -> Signal b1
forall b b1. Signal b -> Signal b1 -> Signal b1
react1 Signal a1
s1 (Signal b1 -> Signal b1)
-> (Signal a3 -> Signal b1) -> Signal a3 -> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> AbstExt a1 -> AbstExt a2 -> AbstExt 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
SY.state31 ((b1 -> a1 -> a2 -> a3 -> b1)
-> b1 -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> b1
forall (b :: * -> *) t a1 a2 a3.
ExB b =>
(t -> a1 -> a2 -> a3 -> t) -> t -> b a1 -> b a2 -> b a3 -> t
B.ignore31 b1 -> a1 -> a2 -> a3 -> b1
ns) b1
i Signal a1
s1 Signal a2
s2)
state32 :: (b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2))
-> (b1, b2)
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2)
state32 ns :: b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2)
ns i :: (b1, b2)
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 = (Signal a1 -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall b b1 b2.
Signal b -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
react2 Signal a1
s1 ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> (Signal a3 -> (Signal b1, Signal b2))
-> Signal a3
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> b2 -> AbstExt a1 -> AbstExt a2 -> AbstExt 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)
SY.state32 ((b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2))
-> b1 -> b2 -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> (b1, b2)
forall (b :: * -> *) t1 t2 a1 a2 a3.
ExB b =>
(t1 -> t2 -> a1 -> a2 -> a3 -> (t1, t2))
-> t1 -> t2 -> b a1 -> b a2 -> b a3 -> (t1, t2)
B.ignore32 b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2)
ns) (b1, b2)
i Signal a1
s1 Signal a2
s2)
state33 :: (b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
state33 ns :: b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 = (Signal a1
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall b b1 b2 b3.
Signal b
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
react3 Signal a1
s1 ((Signal b1, Signal b2, Signal b3)
 -> (Signal b1, Signal b2, Signal b3))
-> (Signal a3 -> (Signal b1, Signal b2, Signal b3))
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1
 -> b2
 -> b3
 -> AbstExt a1
 -> AbstExt a2
 -> AbstExt 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)
SY.state33 ((b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3))
-> b1
-> b2
-> b3
-> AbstExt a1
-> AbstExt a2
-> AbstExt a3
-> (b1, b2, b3)
forall (b :: * -> *) t1 t2 t3 a1 a2 a3.
ExB b =>
(t1 -> t2 -> t3 -> a1 -> a2 -> a3 -> (t1, t2, t3))
-> t1 -> t2 -> t3 -> b a1 -> b a2 -> b a3 -> (t1, t2, t3)
B.ignore33 b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3)
ns) (b1, b2, b3)
i Signal a1
s1 Signal a2
s2)

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

-- | @stated@ is a state machine without an output decoder. It implements the @stated@
-- pattern (see 'ForSyDe.Atom.MoC.stated22'), and operates on
-- 'ForSyDe.Atom.ExB.degen'erated absent-extended values (see
-- 'ForSyDe.Atom.ExB.ignore22') in order to propagate absent events properly and not
-- raise absent-present resolution errors.
--
-- Constructors: @stated[1-3][1-3]@.
--
-- >>> let ones = takeS 8 $ SY.constant1 (Prst 1)
-- >>> let b = (signal . map Prst) [False,True,False,False,True,True,False,True]
-- >>> ones
-- {1,1,1,1,1,1,1,1}
-- >>> b
-- {False,True,False,False,True,True,False,True}
-- >>> stated11 (+) 1 ones
-- {1,2,3,4,5,6,7,8}
-- >>> stated11 (+) 1 (ones `when` b)
-- {⟂,1,⟂,⟂,2,3,⟂,4}
-- >>> stated11 (+) 1 ones `when` b
-- {⟂,2,⟂,⟂,5,6,⟂,8}
stated22 :: (b1 -> b2 -> a1 -> a2 -> (b1, b2))
           -- ^ next stated function
           -> (b1, b2)
           -- ^ initial stated values
           -> Signal a1
           -- ^ first input signal
           -> Signal a2
           -- ^ second input signal
           -> (Signal b1, Signal b2) -- ^ output signals
stated11 :: (b1 -> a1 -> b1) -> b1
        -> Signal a1 -> Signal b1
stated12 :: (b1 -> b2 -> a1 -> (b1, b2)) -> (b1, b2)
        -> Signal a1 -> (Signal b1, Signal b2)
stated13 :: (b1 -> b2 -> b3 -> a1 -> (b1, b2, b3)) -> (b1, b2, b3)
        -> Signal a1 -> (Signal b1, Signal b2, Signal b3)
stated21 :: (b1 -> a1 -> a2 -> b1) -> b1
        -> Signal a1 -> Signal a2 -> Signal b1
stated23 :: (b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3)) -> (b1, b2, b3)
        -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3)
stated31 :: (b1 -> a1 -> a2 -> a3 -> b1) -> b1
        -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
stated32 :: (b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2)) -> (b1, b2)
        -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2)
stated33 :: (b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3)) -> (b1, b2, b3)
        -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2, Signal b3)

stated11 :: (b1 -> a1 -> b1) -> b1 -> Signal a1 -> Signal b1
stated11 ns :: b1 -> a1 -> b1
ns i :: b1
i s1 :: Signal a1
s1    = Signal a1 -> Signal b1 -> Signal b1
forall b b1. Signal b -> Signal b1 -> Signal b1
react1 Signal a1
s1 (Signal b1 -> Signal b1) -> Signal b1 -> Signal b1
forall a b. (a -> b) -> a -> b
$ (b1 -> AbstExt a1 -> b1) -> b1 -> Signal a1 -> Signal b1
forall b1 a1. (b1 -> a1 -> b1) -> b1 -> Signal a1 -> Signal b1
SY.stated11 ((b1 -> a1 -> b1) -> b1 -> AbstExt a1 -> b1
forall (b :: * -> *) t a. ExB b => (t -> a -> t) -> t -> b a -> t
B.ignore11 b1 -> a1 -> b1
ns) b1
i Signal a1
s1
stated12 :: (b1 -> b2 -> a1 -> (b1, b2))
-> (b1, b2) -> Signal a1 -> (Signal b1, Signal b2)
stated12 ns :: b1 -> b2 -> a1 -> (b1, b2)
ns i :: (b1, b2)
i s1 :: Signal a1
s1    = Signal a1 -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall b b1 b2.
Signal b -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
react2 Signal a1
s1 ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall a b. (a -> b) -> a -> b
$ (b1 -> b2 -> AbstExt 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)
SY.stated12 ((b1 -> b2 -> a1 -> (b1, b2)) -> b1 -> b2 -> AbstExt a1 -> (b1, b2)
forall (b :: * -> *) t1 t2 a.
ExB b =>
(t1 -> t2 -> a -> (t1, t2)) -> t1 -> t2 -> b a -> (t1, t2)
B.ignore12 b1 -> b2 -> a1 -> (b1, b2)
ns) (b1, b2)
i Signal a1
s1
stated13 :: (b1 -> b2 -> b3 -> a1 -> (b1, b2, b3))
-> (b1, b2, b3) -> Signal a1 -> (Signal b1, Signal b2, Signal b3)
stated13 ns :: b1 -> b2 -> b3 -> a1 -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: Signal a1
s1    = Signal a1
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall b b1 b2 b3.
Signal b
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
react3 Signal a1
s1 ((Signal b1, Signal b2, Signal b3)
 -> (Signal b1, Signal b2, Signal b3))
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall a b. (a -> b) -> a -> b
$ (b1 -> b2 -> b3 -> AbstExt 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)
SY.stated13 ((b1 -> b2 -> b3 -> a1 -> (b1, b2, b3))
-> b1 -> b2 -> b3 -> AbstExt a1 -> (b1, b2, b3)
forall (b :: * -> *) t1 t2 t3 a.
ExB b =>
(t1 -> t2 -> t3 -> a -> (t1, t2, t3))
-> t1 -> t2 -> t3 -> b a -> (t1, t2, t3)
B.ignore13 b1 -> b2 -> b3 -> a1 -> (b1, b2, b3)
ns) (b1, b2, b3)
i Signal a1
s1
stated21 :: (b1 -> a1 -> a2 -> b1) -> b1 -> Signal a1 -> Signal a2 -> Signal b1
stated21 ns :: b1 -> a1 -> a2 -> b1
ns i :: b1
i s1 :: Signal a1
s1    = Signal a1 -> Signal b1 -> Signal b1
forall b b1. Signal b -> Signal b1 -> Signal b1
react1 Signal a1
s1 (Signal b1 -> Signal b1)
-> (Signal a2 -> Signal b1) -> Signal a2 -> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> AbstExt a1 -> AbstExt a2 -> b1)
-> b1 -> Signal a1 -> Signal a2 -> Signal b1
forall b1 a1 a2.
(b1 -> a1 -> a2 -> b1) -> b1 -> Signal a1 -> Signal a2 -> Signal b1
SY.stated21 ((b1 -> a1 -> a2 -> b1) -> b1 -> AbstExt a1 -> AbstExt a2 -> b1
forall (b :: * -> *) t a1 a2.
ExB b =>
(t -> a1 -> a2 -> t) -> t -> b a1 -> b a2 -> t
B.ignore21 b1 -> a1 -> a2 -> b1
ns) b1
i Signal a1
s1
stated22 :: (b1 -> b2 -> a1 -> a2 -> (b1, b2))
-> (b1, b2) -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
stated22 ns :: b1 -> b2 -> a1 -> a2 -> (b1, b2)
ns i :: (b1, b2)
i s1 :: Signal a1
s1    = Signal a1 -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall b b1 b2.
Signal b -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
react2 Signal a1
s1 ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> (Signal a2 -> (Signal b1, Signal b2))
-> Signal a2
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> b2 -> AbstExt a1 -> AbstExt 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)
SY.stated22 ((b1 -> b2 -> a1 -> a2 -> (b1, b2))
-> b1 -> b2 -> AbstExt a1 -> AbstExt a2 -> (b1, b2)
forall (b :: * -> *) a1 a2 a1' a2'.
ExB b =>
(a1 -> a2 -> a1' -> a2' -> (a1, a2))
-> a1 -> a2 -> b a1' -> b a2' -> (a1, a2)
B.ignore22 b1 -> b2 -> a1 -> a2 -> (b1, b2)
ns) (b1, b2)
i Signal a1
s1
stated23 :: (b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
stated23 ns :: b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: Signal a1
s1    = Signal a1
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall b b1 b2 b3.
Signal b
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
react3 Signal a1
s1 ((Signal b1, Signal b2, Signal b3)
 -> (Signal b1, Signal b2, Signal b3))
-> (Signal a2 -> (Signal b1, Signal b2, Signal b3))
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> b2 -> b3 -> AbstExt a1 -> AbstExt 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)
SY.stated23 ((b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3))
-> b1 -> b2 -> b3 -> AbstExt a1 -> AbstExt a2 -> (b1, b2, b3)
forall (b :: * -> *) t1 t2 t3 a1 a2.
ExB b =>
(t1 -> t2 -> t3 -> a1 -> a2 -> (t1, t2, t3))
-> t1 -> t2 -> t3 -> b a1 -> b a2 -> (t1, t2, t3)
B.ignore23 b1 -> b2 -> b3 -> a1 -> a2 -> (b1, b2, b3)
ns) (b1, b2, b3)
i Signal a1
s1
stated31 :: (b1 -> a1 -> a2 -> a3 -> b1)
-> b1 -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
stated31 ns :: b1 -> a1 -> a2 -> a3 -> b1
ns i :: b1
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 = Signal a1 -> Signal b1 -> Signal b1
forall b b1. Signal b -> Signal b1 -> Signal b1
react1 Signal a1
s1 (Signal b1 -> Signal b1)
-> (Signal a3 -> Signal b1) -> Signal a3 -> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> AbstExt a1 -> AbstExt a2 -> AbstExt 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
SY.stated31 ((b1 -> a1 -> a2 -> a3 -> b1)
-> b1 -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> b1
forall (b :: * -> *) t a1 a2 a3.
ExB b =>
(t -> a1 -> a2 -> a3 -> t) -> t -> b a1 -> b a2 -> b a3 -> t
B.ignore31 b1 -> a1 -> a2 -> a3 -> b1
ns) b1
i Signal a1
s1 Signal a2
s2
stated32 :: (b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2))
-> (b1, b2)
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2)
stated32 ns :: b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2)
ns i :: (b1, b2)
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 = Signal a1 -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall b b1 b2.
Signal b -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
react2 Signal a1
s1 ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> (Signal a3 -> (Signal b1, Signal b2))
-> Signal a3
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1 -> b2 -> AbstExt a1 -> AbstExt a2 -> AbstExt 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)
SY.stated32 ((b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2))
-> b1 -> b2 -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> (b1, b2)
forall (b :: * -> *) t1 t2 a1 a2 a3.
ExB b =>
(t1 -> t2 -> a1 -> a2 -> a3 -> (t1, t2))
-> t1 -> t2 -> b a1 -> b a2 -> b a3 -> (t1, t2)
B.ignore32 b1 -> b2 -> a1 -> a2 -> a3 -> (b1, b2)
ns) (b1, b2)
i Signal a1
s1 Signal a2
s2
stated33 :: (b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3))
-> (b1, b2, b3)
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
stated33 ns :: b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3)
ns i :: (b1, b2, b3)
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 = Signal a1
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall b b1 b2 b3.
Signal b
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
react3 Signal a1
s1 ((Signal b1, Signal b2, Signal b3)
 -> (Signal b1, Signal b2, Signal b3))
-> (Signal a3 -> (Signal b1, Signal b2, Signal b3))
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b1
 -> b2
 -> b3
 -> AbstExt a1
 -> AbstExt a2
 -> AbstExt 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)
SY.stated33 ((b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3))
-> b1
-> b2
-> b3
-> AbstExt a1
-> AbstExt a2
-> AbstExt a3
-> (b1, b2, b3)
forall (b :: * -> *) t1 t2 t3 a1 a2 a3.
ExB b =>
(t1 -> t2 -> t3 -> a1 -> a2 -> a3 -> (t1, t2, t3))
-> t1 -> t2 -> t3 -> b a1 -> b a2 -> b a3 -> (t1, t2, t3)
B.ignore33 b1 -> b2 -> b3 -> a1 -> a2 -> a3 -> (b1, b2, b3)
ns) (b1, b2, b3)
i Signal a1
s1 Signal a2
s2


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

-- | @moore@ processes model Moore state machines. It implements the @moore@ patterns
-- (see 'ForSyDe.Atom.MoC.moore22'), and operates on absent-extended values (see
-- 'stated22').
--
-- Constructors: @moore[1-3][1-3]@.
--
-- >>> let s1 = signal [Prst 1,Prst 2,Abst,Abst,Prst 3]  
-- >>> moore11 (+) (+1) 1 s1
-- {2,3,⟂,⟂,5}
moore22 :: (st -> a1 -> a2 -> st)
           -- ^ next state function
           -> (st -> (b1, b2))
           -- ^ output decoder
           -> st
           -- ^ initial state
           -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
moore11 :: (st -> a1 -> st) -> (st -> b1) -> st
        -> Signal a1 -> Signal b1
moore12 :: (st -> a1 -> st) -> (st -> (b1, b2)) -> st
        -> Signal a1 -> (Signal b1, Signal b2)
moore13 :: (st -> a1 -> st) -> (st -> (b1, b2, b3)) -> st
        -> Signal a1 -> (Signal b1, Signal b2, Signal b3)
moore21 :: (st -> a1 -> a2 -> st) -> (st -> b1) -> st
        -> Signal a1 -> Signal a2 -> Signal b1
moore23 :: (st -> a1 -> a2 -> st) -> (st -> (b1, b2, b3)) -> st
        -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3)
moore31 :: (st -> a1 -> a2 -> a3 -> st) -> (st -> b1) -> st
        -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
moore32 :: (st -> a1 -> a2 -> a3 -> st) -> (st -> (b1, b2)) -> st
        -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2)
moore33 :: (st -> a1 -> a2 -> a3 -> st) -> (st -> (b1, b2, b3)) -> st
        -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2, Signal b3)

moore11 :: (st -> a1 -> st) -> (st -> b1) -> st -> Signal a1 -> Signal b1
moore11 ns :: st -> a1 -> st
ns od :: st -> b1
od i :: st
i s1 :: Signal a1
s1    = Signal a1 -> Signal b1 -> Signal b1
forall b b1. Signal b -> Signal b1 -> Signal b1
react1 Signal a1
s1 (Signal b1 -> Signal b1) -> Signal b1 -> Signal b1
forall a b. (a -> b) -> a -> b
$ (st -> AbstExt a1 -> st)
-> (st -> b1) -> st -> Signal a1 -> Signal b1
forall st a1 b1.
(st -> a1 -> st) -> (st -> b1) -> st -> Signal a1 -> Signal b1
SY.moore11 ((st -> a1 -> st) -> st -> AbstExt a1 -> st
forall (b :: * -> *) t a. ExB b => (t -> a -> t) -> t -> b a -> t
B.ignore11 st -> a1 -> st
ns) st -> b1
od st
i Signal a1
s1
moore12 :: (st -> a1 -> st)
-> (st -> (b1, b2)) -> st -> Signal a1 -> (Signal b1, Signal b2)
moore12 ns :: st -> a1 -> st
ns od :: st -> (b1, b2)
od i :: st
i s1 :: Signal a1
s1    = Signal a1 -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall b b1 b2.
Signal b -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
react2 Signal a1
s1 ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall a b. (a -> b) -> a -> b
$ (st -> AbstExt a1 -> st)
-> (st -> (b1, b2)) -> st -> Signal a1 -> (Signal b1, Signal b2)
forall st a1 b1 b2.
(st -> a1 -> st)
-> (st -> (b1, b2)) -> st -> Signal a1 -> (Signal b1, Signal b2)
SY.moore12 ((st -> a1 -> st) -> st -> AbstExt a1 -> st
forall (b :: * -> *) t a. ExB b => (t -> a -> t) -> t -> b a -> t
B.ignore11 st -> a1 -> st
ns) st -> (b1, b2)
od st
i Signal a1
s1
moore13 :: (st -> a1 -> st)
-> (st -> (b1, b2, b3))
-> st
-> Signal a1
-> (Signal b1, Signal b2, Signal b3)
moore13 ns :: st -> a1 -> st
ns od :: st -> (b1, b2, b3)
od i :: st
i s1 :: Signal a1
s1    = Signal a1
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall b b1 b2 b3.
Signal b
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
react3 Signal a1
s1 ((Signal b1, Signal b2, Signal b3)
 -> (Signal b1, Signal b2, Signal b3))
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall a b. (a -> b) -> a -> b
$ (st -> AbstExt a1 -> st)
-> (st -> (b1, b2, b3))
-> st
-> Signal a1
-> (Signal b1, Signal b2, Signal b3)
forall st a1 b1 b2 b3.
(st -> a1 -> st)
-> (st -> (b1, b2, b3))
-> st
-> Signal a1
-> (Signal b1, Signal b2, Signal b3)
SY.moore13 ((st -> a1 -> st) -> st -> AbstExt a1 -> st
forall (b :: * -> *) t a. ExB b => (t -> a -> t) -> t -> b a -> t
B.ignore11 st -> a1 -> st
ns) st -> (b1, b2, b3)
od st
i Signal a1
s1
moore21 :: (st -> a1 -> a2 -> st)
-> (st -> b1) -> st -> Signal a1 -> Signal a2 -> Signal b1
moore21 ns :: st -> a1 -> a2 -> st
ns od :: st -> b1
od i :: st
i s1 :: Signal a1
s1    = Signal a1 -> Signal b1 -> Signal b1
forall b b1. Signal b -> Signal b1 -> Signal b1
react1 Signal a1
s1 (Signal b1 -> Signal b1)
-> (Signal a2 -> Signal b1) -> Signal a2 -> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (st -> AbstExt a1 -> AbstExt a2 -> st)
-> (st -> b1) -> st -> Signal a1 -> Signal a2 -> Signal b1
forall st a1 a2 b1.
(st -> a1 -> a2 -> st)
-> (st -> b1) -> st -> Signal a1 -> Signal a2 -> Signal b1
SY.moore21 ((st -> a1 -> a2 -> st) -> st -> AbstExt a1 -> AbstExt a2 -> st
forall (b :: * -> *) t a1 a2.
ExB b =>
(t -> a1 -> a2 -> t) -> t -> b a1 -> b a2 -> t
B.ignore21 st -> a1 -> a2 -> st
ns) st -> b1
od st
i Signal a1
s1
moore22 :: (st -> a1 -> a2 -> st)
-> (st -> (b1, b2))
-> st
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2)
moore22 ns :: st -> a1 -> a2 -> st
ns od :: st -> (b1, b2)
od i :: st
i s1 :: Signal a1
s1    = Signal a1 -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall b b1 b2.
Signal b -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
react2 Signal a1
s1 ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> (Signal a2 -> (Signal b1, Signal b2))
-> Signal a2
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (st -> AbstExt a1 -> AbstExt a2 -> st)
-> (st -> (b1, b2))
-> st
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2)
forall st a1 a2 b1 b2.
(st -> a1 -> a2 -> st)
-> (st -> (b1, b2))
-> st
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2)
SY.moore22 ((st -> a1 -> a2 -> st) -> st -> AbstExt a1 -> AbstExt a2 -> st
forall (b :: * -> *) t a1 a2.
ExB b =>
(t -> a1 -> a2 -> t) -> t -> b a1 -> b a2 -> t
B.ignore21 st -> a1 -> a2 -> st
ns) st -> (b1, b2)
od st
i Signal a1
s1
moore23 :: (st -> a1 -> a2 -> st)
-> (st -> (b1, b2, b3))
-> st
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
moore23 ns :: st -> a1 -> a2 -> st
ns od :: st -> (b1, b2, b3)
od i :: st
i s1 :: Signal a1
s1    = Signal a1
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall b b1 b2 b3.
Signal b
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
react3 Signal a1
s1 ((Signal b1, Signal b2, Signal b3)
 -> (Signal b1, Signal b2, Signal b3))
-> (Signal a2 -> (Signal b1, Signal b2, Signal b3))
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (st -> AbstExt a1 -> AbstExt a2 -> st)
-> (st -> (b1, b2, b3))
-> st
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
forall st a1 a2 b1 b2 b3.
(st -> a1 -> a2 -> st)
-> (st -> (b1, b2, b3))
-> st
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
SY.moore23 ((st -> a1 -> a2 -> st) -> st -> AbstExt a1 -> AbstExt a2 -> st
forall (b :: * -> *) t a1 a2.
ExB b =>
(t -> a1 -> a2 -> t) -> t -> b a1 -> b a2 -> t
B.ignore21 st -> a1 -> a2 -> st
ns) st -> (b1, b2, b3)
od st
i Signal a1
s1
moore31 :: (st -> a1 -> a2 -> a3 -> st)
-> (st -> b1)
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal b1
moore31 ns :: st -> a1 -> a2 -> a3 -> st
ns od :: st -> b1
od i :: st
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 = Signal a1 -> Signal b1 -> Signal b1
forall b b1. Signal b -> Signal b1 -> Signal b1
react1 Signal a1
s1 (Signal b1 -> Signal b1)
-> (Signal a3 -> Signal b1) -> Signal a3 -> Signal b1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (st -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> st)
-> (st -> b1)
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal b1
forall st a1 a2 a3 b1.
(st -> a1 -> a2 -> a3 -> st)
-> (st -> b1)
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal b1
SY.moore31 ((st -> a1 -> a2 -> a3 -> st)
-> st -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> st
forall (b :: * -> *) t a1 a2 a3.
ExB b =>
(t -> a1 -> a2 -> a3 -> t) -> t -> b a1 -> b a2 -> b a3 -> t
B.ignore31 st -> a1 -> a2 -> a3 -> st
ns) st -> b1
od st
i Signal a1
s1 Signal a2
s2
moore32 :: (st -> a1 -> a2 -> a3 -> st)
-> (st -> (b1, b2))
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2)
moore32 ns :: st -> a1 -> a2 -> a3 -> st
ns od :: st -> (b1, b2)
od i :: st
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 = Signal a1 -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
forall b b1 b2.
Signal b -> (Signal b1, Signal b2) -> (Signal b1, Signal b2)
react2 Signal a1
s1 ((Signal b1, Signal b2) -> (Signal b1, Signal b2))
-> (Signal a3 -> (Signal b1, Signal b2))
-> Signal a3
-> (Signal b1, Signal b2)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (st -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> st)
-> (st -> (b1, b2))
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2)
forall st a1 a2 a3 b1 b2.
(st -> a1 -> a2 -> a3 -> st)
-> (st -> (b1, b2))
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2)
SY.moore32 ((st -> a1 -> a2 -> a3 -> st)
-> st -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> st
forall (b :: * -> *) t a1 a2 a3.
ExB b =>
(t -> a1 -> a2 -> a3 -> t) -> t -> b a1 -> b a2 -> b a3 -> t
B.ignore31 st -> a1 -> a2 -> a3 -> st
ns) st -> (b1, b2)
od st
i Signal a1
s1 Signal a2
s2
moore33 :: (st -> a1 -> a2 -> a3 -> st)
-> (st -> (b1, b2, b3))
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
moore33 ns :: st -> a1 -> a2 -> a3 -> st
ns od :: st -> (b1, b2, b3)
od i :: st
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 = Signal a1
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
forall b b1 b2 b3.
Signal b
-> (Signal b1, Signal b2, Signal b3)
-> (Signal b1, Signal b2, Signal b3)
react3 Signal a1
s1 ((Signal b1, Signal b2, Signal b3)
 -> (Signal b1, Signal b2, Signal b3))
-> (Signal a3 -> (Signal b1, Signal b2, Signal b3))
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (st -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> st)
-> (st -> (b1, b2, b3))
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
forall st a1 a2 a3 b1 b2 b3.
(st -> a1 -> a2 -> a3 -> st)
-> (st -> (b1, b2, b3))
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
SY.moore33 ((st -> a1 -> a2 -> a3 -> st)
-> st -> AbstExt a1 -> AbstExt a2 -> AbstExt a3 -> st
forall (b :: * -> *) t a1 a2 a3.
ExB b =>
(t -> a1 -> a2 -> a3 -> t) -> t -> b a1 -> b a2 -> b a3 -> t
B.ignore31 st -> a1 -> a2 -> a3 -> st
ns) st -> (b1, b2, b3)
od st
i Signal a1
s1 Signal a2
s2


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

-- | @mealy@ processes model Mealy state machines. It implements the @mealy@ pattern
-- (see 'ForSyDe.Atom.MoC.mealy22'), and operates on absent-extended values (see
-- 'stated22').
--
-- Constructors: @mealy[1-3][1-3]@.
--
-- >>> let s1 = signal [Prst 1,Prst 2,Abst,Abst,Prst 3]  
-- >>> mealy11 (+) (+) 1 s1
-- {2,4,⟂,⟂,7}
mealy22 :: (st -> a1 -> a2 -> st)
           -- ^ next state function
           -> (st -> a1 -> a2 -> (b1, b2))
           -- ^ outpt decoder
           -> st
           -- ^ initial state
           -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
mealy11 :: (st -> a1 -> st) -> (st -> a1 -> b1) -> st
        -> Signal a1 -> Signal b1
mealy12 :: (st -> a1 -> st) -> (st -> a1 -> (b1, b2)) -> st
        -> Signal a1 -> (Signal b1, Signal b2)
mealy13 :: (st -> a1 -> st) -> (st -> a1 -> (b1, b2, b3)) -> st
        -> Signal a1 -> (Signal b1, Signal b2, Signal b3)
mealy21 :: (st -> a1 -> a2 -> st) -> (st -> a1 -> a2 -> b1) -> st
        -> Signal a1 -> Signal a2 -> Signal b1
mealy23 :: (st -> a1 -> a2 -> st) -> (st -> a1 -> a2 -> (b1, b2, b3)) -> st
        -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3)
mealy31 :: (st -> a1 -> a2 -> a3 -> st) -> (st -> a1 -> a2 -> a3 -> b1) -> st
        -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
mealy32 :: (st -> a1 -> a2 -> a3 -> st) -> (st -> a1 -> a2 -> a3 -> (b1, b2)) -> st
        -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2)
mealy33 :: (st -> a1 -> a2 -> a3 -> st) -> (st -> a1 -> a2 -> a3 -> (b1, b2, b3)) -> st
        -> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2, Signal b3)

mealy11 :: (st -> a1 -> st)
-> (st -> a1 -> b1) -> st -> Signal a1 -> Signal b1
mealy11 ns :: st -> a1 -> st
ns od :: st -> a1 -> b1
od i :: st
i s1 :: Signal a1
s1       = (st -> a1 -> b1) -> Signal st -> Signal a1 -> Signal b1
forall a1 a2 b1.
(a1 -> a2 -> b1) -> Signal a1 -> Signal a2 -> Signal b1
comb21 st -> a1 -> b1
od ((st -> a1 -> st) -> st -> Signal a1 -> Signal st
forall b1 a1. (b1 -> a1 -> b1) -> b1 -> Signal a1 -> Signal b1
stated11 st -> a1 -> st
ns st
i Signal a1
s1) Signal a1
s1
mealy12 :: (st -> a1 -> st)
-> (st -> a1 -> (b1, b2))
-> st
-> Signal a1
-> (Signal b1, Signal b2)
mealy12 ns :: st -> a1 -> st
ns od :: st -> a1 -> (b1, b2)
od i :: st
i s1 :: Signal a1
s1       = (st -> a1 -> (b1, b2))
-> Signal st -> Signal a1 -> (Signal b1, Signal b2)
forall a1 a2 b1 b2.
(a1 -> a2 -> (b1, b2))
-> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
comb22 st -> a1 -> (b1, b2)
od ((st -> a1 -> st) -> st -> Signal a1 -> Signal st
forall b1 a1. (b1 -> a1 -> b1) -> b1 -> Signal a1 -> Signal b1
stated11 st -> a1 -> st
ns st
i Signal a1
s1) Signal a1
s1
mealy13 :: (st -> a1 -> st)
-> (st -> a1 -> (b1, b2, b3))
-> st
-> Signal a1
-> (Signal b1, Signal b2, Signal b3)
mealy13 ns :: st -> a1 -> st
ns od :: st -> a1 -> (b1, b2, b3)
od i :: st
i s1 :: Signal a1
s1       = (st -> a1 -> (b1, b2, b3))
-> Signal st -> Signal a1 -> (Signal b1, Signal b2, Signal b3)
forall a1 a2 b1 b2 b3.
(a1 -> a2 -> (b1, b2, b3))
-> Signal a1 -> Signal a2 -> (Signal b1, Signal b2, Signal b3)
comb23 st -> a1 -> (b1, b2, b3)
od ((st -> a1 -> st) -> st -> Signal a1 -> Signal st
forall b1 a1. (b1 -> a1 -> b1) -> b1 -> Signal a1 -> Signal b1
stated11 st -> a1 -> st
ns st
i Signal a1
s1) Signal a1
s1
mealy21 :: (st -> a1 -> a2 -> st)
-> (st -> a1 -> a2 -> b1)
-> st
-> Signal a1
-> Signal a2
-> Signal b1
mealy21 ns :: st -> a1 -> a2 -> st
ns od :: st -> a1 -> a2 -> b1
od i :: st
i s1 :: Signal a1
s1 s2 :: Signal a2
s2    = (st -> a1 -> a2 -> b1)
-> Signal st -> Signal a1 -> Signal a2 -> Signal b1
forall a1 a2 a3 b1.
(a1 -> a2 -> a3 -> b1)
-> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
comb31 st -> a1 -> a2 -> b1
od ((st -> a1 -> a2 -> st) -> st -> Signal a1 -> Signal a2 -> Signal st
forall b1 a1 a2.
(b1 -> a1 -> a2 -> b1) -> b1 -> Signal a1 -> Signal a2 -> Signal b1
stated21 st -> a1 -> a2 -> st
ns st
i Signal a1
s1 Signal a2
s2) Signal a1
s1 Signal a2
s2
mealy22 :: (st -> a1 -> a2 -> st)
-> (st -> a1 -> a2 -> (b1, b2))
-> st
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2)
mealy22 ns :: st -> a1 -> a2 -> st
ns od :: st -> a1 -> a2 -> (b1, b2)
od i :: st
i s1 :: Signal a1
s1 s2 :: Signal a2
s2    = (st -> a1 -> a2 -> (b1, b2))
-> Signal st -> Signal a1 -> Signal a2 -> (Signal b1, Signal b2)
forall a1 a2 a3 b1 b2.
(a1 -> a2 -> a3 -> (b1, b2))
-> Signal a1 -> Signal a2 -> Signal a3 -> (Signal b1, Signal b2)
comb32 st -> a1 -> a2 -> (b1, b2)
od ((st -> a1 -> a2 -> st) -> st -> Signal a1 -> Signal a2 -> Signal st
forall b1 a1 a2.
(b1 -> a1 -> a2 -> b1) -> b1 -> Signal a1 -> Signal a2 -> Signal b1
stated21 st -> a1 -> a2 -> st
ns st
i Signal a1
s1 Signal a2
s2) Signal a1
s1 Signal a2
s2
mealy23 :: (st -> a1 -> a2 -> st)
-> (st -> a1 -> a2 -> (b1, b2, b3))
-> st
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
mealy23 ns :: st -> a1 -> a2 -> st
ns od :: st -> a1 -> a2 -> (b1, b2, b3)
od i :: st
i s1 :: Signal a1
s1 s2 :: Signal a2
s2    = (st -> a1 -> a2 -> (b1, b2, b3))
-> Signal st
-> Signal a1
-> Signal a2
-> (Signal b1, Signal b2, Signal b3)
forall a1 a2 a3 b1 b2 b3.
(a1 -> a2 -> a3 -> (b1, b2, b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
comb33 st -> a1 -> a2 -> (b1, b2, b3)
od ((st -> a1 -> a2 -> st) -> st -> Signal a1 -> Signal a2 -> Signal st
forall b1 a1 a2.
(b1 -> a1 -> a2 -> b1) -> b1 -> Signal a1 -> Signal a2 -> Signal b1
stated21 st -> a1 -> a2 -> st
ns st
i Signal a1
s1 Signal a2
s2) Signal a1
s1 Signal a2
s2
mealy31 :: (st -> a1 -> a2 -> a3 -> st)
-> (st -> a1 -> a2 -> a3 -> b1)
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal b1
mealy31 ns :: st -> a1 -> a2 -> a3 -> st
ns od :: st -> a1 -> a2 -> a3 -> b1
od i :: st
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 s3 :: Signal a3
s3 = (st -> a1 -> a2 -> a3 -> b1)
-> Signal st -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
forall a1 a2 a3 a4 b1.
(a1 -> a2 -> a3 -> a4 -> b1)
-> Signal a1 -> Signal a2 -> Signal a3 -> Signal a4 -> Signal b1
comb41 st -> a1 -> a2 -> a3 -> b1
od ((st -> a1 -> a2 -> a3 -> st)
-> st -> Signal a1 -> Signal a2 -> Signal a3 -> Signal st
forall b1 a1 a2 a3.
(b1 -> a1 -> a2 -> a3 -> b1)
-> b1 -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
stated31 st -> a1 -> a2 -> a3 -> st
ns st
i Signal a1
s1 Signal a2
s2 Signal a3
s3) Signal a1
s1 Signal a2
s2 Signal a3
s3
mealy32 :: (st -> a1 -> a2 -> a3 -> st)
-> (st -> a1 -> a2 -> a3 -> (b1, b2))
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2)
mealy32 ns :: st -> a1 -> a2 -> a3 -> st
ns od :: st -> a1 -> a2 -> a3 -> (b1, b2)
od i :: st
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 s3 :: Signal a3
s3 = (st -> a1 -> a2 -> a3 -> (b1, b2))
-> Signal st
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2)
forall a1 a2 a3 a4 b1 b2.
(a1 -> a2 -> a3 -> a4 -> (b1, b2))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2)
comb42 st -> a1 -> a2 -> a3 -> (b1, b2)
od ((st -> a1 -> a2 -> a3 -> st)
-> st -> Signal a1 -> Signal a2 -> Signal a3 -> Signal st
forall b1 a1 a2 a3.
(b1 -> a1 -> a2 -> a3 -> b1)
-> b1 -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
stated31 st -> a1 -> a2 -> a3 -> st
ns st
i Signal a1
s1 Signal a2
s2 Signal a3
s3) Signal a1
s1 Signal a2
s2 Signal a3
s3
mealy33 :: (st -> a1 -> a2 -> a3 -> st)
-> (st -> a1 -> a2 -> a3 -> (b1, b2, b3))
-> st
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
mealy33 ns :: st -> a1 -> a2 -> a3 -> st
ns od :: st -> a1 -> a2 -> a3 -> (b1, b2, b3)
od i :: st
i s1 :: Signal a1
s1 s2 :: Signal a2
s2 s3 :: Signal a3
s3 = (st -> a1 -> a2 -> a3 -> (b1, b2, b3))
-> Signal st
-> Signal a1
-> Signal a2
-> Signal a3
-> (Signal b1, Signal b2, Signal b3)
forall a1 a2 a3 a4 b1 b2 b3.
(a1 -> a2 -> a3 -> a4 -> (b1, b2, b3))
-> Signal a1
-> Signal a2
-> Signal a3
-> Signal a4
-> (Signal b1, Signal b2, Signal b3)
comb43 st -> a1 -> a2 -> a3 -> (b1, b2, b3)
od ((st -> a1 -> a2 -> a3 -> st)
-> st -> Signal a1 -> Signal a2 -> Signal a3 -> Signal st
forall b1 a1 a2 a3.
(b1 -> a1 -> a2 -> a3 -> b1)
-> b1 -> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
stated31 st -> a1 -> a2 -> a3 -> st
ns st
i Signal a1
s1 Signal a2
s2 Signal a3
s3) Signal a1
s1 Signal a2
s2 Signal a3
s3


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