{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
module FRP.Rhine.SN.Combinators where
import FRP.Rhine.ClSF.Core
import FRP.Rhine.Clock
import FRP.Rhine.Clock.Proxy
import FRP.Rhine.ResamplingBuffer.Util
import FRP.Rhine.SN
import FRP.Rhine.Schedule
(>>>^)
:: Monad m
=> SN m cl a b
-> (b -> c)
-> SN m cl a c
Synchronous ClSF m cl a b
clsf >>>^ :: forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ b -> c
f = ClSF m cl a c -> SN m cl a c
forall cl (m :: Type -> Type) a b.
(cl ~ In cl, cl ~ Out cl) =>
ClSF m cl a b -> SN m cl a b
Synchronous (ClSF m cl a c -> SN m cl a c) -> ClSF m cl a c -> SN m cl a c
forall a b. (a -> b) -> a -> b
$ ClSF m cl a b
clsf ClSF m cl a b -> (b -> c) -> ClSF m cl a c
forall (a :: Type -> Type -> Type) b c d.
Arrow a =>
a b c -> (c -> d) -> a b d
>>^ b -> c
f
Sequential SN m clab a b1
sn1 ResamplingBuffer m (Out clab) (In clcd) b1 c
rb SN m clcd c b
sn2 >>>^ b -> c
f = SN m clab a b1
-> ResamplingBuffer m (Out clab) (In clcd) b1 c
-> SN m clcd c c
-> SN m (SequentialClock clab clcd) a c
forall (m :: Type -> Type) clab clcd a b1 c b.
(Clock m clab, Clock m clcd, Clock m (Out clab),
Clock m (Out clcd), Clock m (In clab), Clock m (In clcd),
GetClockProxy clab, GetClockProxy clcd, Time clab ~ Time clcd,
Time clab ~ Time (Out clab), Time clcd ~ Time (In clcd)) =>
SN m clab a b1
-> ResamplingBuffer m (Out clab) (In clcd) b1 c
-> SN m clcd c b
-> SN m (SequentialClock clab clcd) a b
Sequential SN m clab a b1
sn1 ResamplingBuffer m (Out clab) (In clcd) b1 c
rb (SN m clcd c c -> SN m (SequentialClock clab clcd) a c)
-> SN m clcd c c -> SN m (SequentialClock clab clcd) a c
forall a b. (a -> b) -> a -> b
$ SN m clcd c b
sn2 SN m clcd c b -> (b -> c) -> SN m clcd c c
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ b -> c
f
Parallel SN m cl1 a b
sn1 SN m cl2 a b
sn2 >>>^ b -> c
f = SN m cl1 a c -> SN m cl2 a c -> SN m (ParallelClock cl1 cl2) a c
forall (m :: Type -> Type) cl1 cl2 a b.
(Clock m cl1, Clock m cl2, Clock m (Out cl1), Clock m (Out cl2),
GetClockProxy cl1, GetClockProxy cl2, Time cl1 ~ Time (Out cl1),
Time cl2 ~ Time (Out cl2), Time cl1 ~ Time cl2,
Time cl1 ~ Time (In cl1), Time cl2 ~ Time (In cl2)) =>
SN m cl1 a b -> SN m cl2 a b -> SN m (ParallelClock cl1 cl2) a b
Parallel (SN m cl1 a b
sn1 SN m cl1 a b -> (b -> c) -> SN m cl1 a c
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ b -> c
f) (SN m cl2 a b
sn2 SN m cl2 a b -> (b -> c) -> SN m cl2 a c
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ b -> c
f)
Postcompose SN m cl a b1
sn ClSF m (Out cl) b1 b
clsf >>>^ b -> c
f = SN m cl a b1
-> Automaton (ReaderT (TimeInfo (Out cl)) m) b1 c -> SN m cl a c
forall (m :: Type -> Type) cl a b1 b.
(Clock m (Out cl), Time cl ~ Time (Out cl)) =>
SN m cl a b1 -> ClSF m (Out cl) b1 b -> SN m cl a b
Postcompose SN m cl a b1
sn (Automaton (ReaderT (TimeInfo (Out cl)) m) b1 c -> SN m cl a c)
-> Automaton (ReaderT (TimeInfo (Out cl)) m) b1 c -> SN m cl a c
forall a b. (a -> b) -> a -> b
$ ClSF m (Out cl) b1 b
clsf ClSF m (Out cl) b1 b
-> (b -> c) -> Automaton (ReaderT (TimeInfo (Out cl)) m) b1 c
forall (a :: Type -> Type -> Type) b c d.
Arrow a =>
a b c -> (c -> d) -> a b d
>>^ b -> c
f
Precompose ClSF m (In cl) a b1
clsf SN m cl b1 b
sn >>>^ b -> c
f = ClSF m (In cl) a b1 -> SN m cl b1 c -> SN m cl a c
forall (m :: Type -> Type) cl a b1 b.
(Clock m (In cl), Time cl ~ Time (In cl)) =>
ClSF m (In cl) a b1 -> SN m cl b1 b -> SN m cl a b
Precompose ClSF m (In cl) a b1
clsf (SN m cl b1 c -> SN m cl a c) -> SN m cl b1 c -> SN m cl a c
forall a b. (a -> b) -> a -> b
$ SN m cl b1 b
sn SN m cl b1 b -> (b -> c) -> SN m cl b1 c
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ b -> c
f
Feedback ResBuf m (Out cl) (In cl) d c
buf SN m cl (a, c) (b, d)
sn >>>^ b -> c
f = ResBuf m (Out cl) (In cl) d c
-> SN m cl (a, c) (c, d) -> SN m cl a c
forall (m :: Type -> Type) cl d c a b.
(Clock m (In cl), Clock m (Out cl), Time (In cl) ~ Time cl,
Time (Out cl) ~ Time cl) =>
ResBuf m (Out cl) (In cl) d c
-> SN m cl (a, c) (b, d) -> SN m cl a b
Feedback ResBuf m (Out cl) (In cl) d c
buf (SN m cl (a, c) (c, d) -> SN m cl a c)
-> SN m cl (a, c) (c, d) -> SN m cl a c
forall a b. (a -> b) -> a -> b
$ SN m cl (a, c) (b, d)
sn SN m cl (a, c) (b, d)
-> ((b, d) -> (c, d)) -> SN m cl (a, c) (c, d)
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ (b -> c) -> (b, d) -> (c, d)
forall b c d. (b -> c) -> (b, d) -> (c, d)
forall (a :: Type -> Type -> Type) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first b -> c
f
firstResampling :: SN m cl a b
firstResampling@(FirstResampling SN m cl a1 b1
_ ResamplingBuffer m (In cl) (Out cl) c d
_) >>>^ b -> c
f = SN m cl a b
-> Automaton (ReaderT (TimeInfo (Out cl)) m) b c -> SN m cl a c
forall (m :: Type -> Type) cl a b1 b.
(Clock m (Out cl), Time cl ~ Time (Out cl)) =>
SN m cl a b1 -> ClSF m (Out cl) b1 b -> SN m cl a b
Postcompose SN m cl a b
firstResampling (Automaton (ReaderT (TimeInfo (Out cl)) m) b c -> SN m cl a c)
-> Automaton (ReaderT (TimeInfo (Out cl)) m) b c -> SN m cl a c
forall a b. (a -> b) -> a -> b
$ (b -> c) -> Automaton (ReaderT (TimeInfo (Out cl)) m) b c
forall b c.
(b -> c) -> Automaton (ReaderT (TimeInfo (Out cl)) m) b c
forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr b -> c
f
(^>>>)
:: Monad m
=> (a -> b)
-> SN m cl b c
-> SN m cl a c
a -> b
f ^>>> :: forall (m :: Type -> Type) a b cl c.
Monad m =>
(a -> b) -> SN m cl b c -> SN m cl a c
^>>> Synchronous ClSF m cl b c
clsf = ClSF m cl a c -> SN m cl a c
forall cl (m :: Type -> Type) a b.
(cl ~ In cl, cl ~ Out cl) =>
ClSF m cl a b -> SN m cl a b
Synchronous (ClSF m cl a c -> SN m cl a c) -> ClSF m cl a c -> SN m cl a c
forall a b. (a -> b) -> a -> b
$ a -> b
f (a -> b) -> ClSF m cl b c -> ClSF m cl a c
forall (a :: Type -> Type -> Type) b c d.
Arrow a =>
(b -> c) -> a c d -> a b d
^>> ClSF m cl b c
clsf
a -> b
f ^>>> Sequential SN m clab b b1
sn1 ResamplingBuffer m (Out clab) (In clcd) b1 c
rb SN m clcd c c
sn2 = SN m clab a b1
-> ResamplingBuffer m (Out clab) (In clcd) b1 c
-> SN m clcd c c
-> SN m (SequentialClock clab clcd) a c
forall (m :: Type -> Type) clab clcd a b1 c b.
(Clock m clab, Clock m clcd, Clock m (Out clab),
Clock m (Out clcd), Clock m (In clab), Clock m (In clcd),
GetClockProxy clab, GetClockProxy clcd, Time clab ~ Time clcd,
Time clab ~ Time (Out clab), Time clcd ~ Time (In clcd)) =>
SN m clab a b1
-> ResamplingBuffer m (Out clab) (In clcd) b1 c
-> SN m clcd c b
-> SN m (SequentialClock clab clcd) a b
Sequential (a -> b
f (a -> b) -> SN m clab b b1 -> SN m clab a b1
forall (m :: Type -> Type) a b cl c.
Monad m =>
(a -> b) -> SN m cl b c -> SN m cl a c
^>>> SN m clab b b1
sn1) ResamplingBuffer m (Out clab) (In clcd) b1 c
rb SN m clcd c c
sn2
a -> b
f ^>>> Parallel SN m cl1 b c
sn1 SN m cl2 b c
sn2 = SN m cl1 a c -> SN m cl2 a c -> SN m (ParallelClock cl1 cl2) a c
forall (m :: Type -> Type) cl1 cl2 a b.
(Clock m cl1, Clock m cl2, Clock m (Out cl1), Clock m (Out cl2),
GetClockProxy cl1, GetClockProxy cl2, Time cl1 ~ Time (Out cl1),
Time cl2 ~ Time (Out cl2), Time cl1 ~ Time cl2,
Time cl1 ~ Time (In cl1), Time cl2 ~ Time (In cl2)) =>
SN m cl1 a b -> SN m cl2 a b -> SN m (ParallelClock cl1 cl2) a b
Parallel (a -> b
f (a -> b) -> SN m cl1 b c -> SN m cl1 a c
forall (m :: Type -> Type) a b cl c.
Monad m =>
(a -> b) -> SN m cl b c -> SN m cl a c
^>>> SN m cl1 b c
sn1) (a -> b
f (a -> b) -> SN m cl2 b c -> SN m cl2 a c
forall (m :: Type -> Type) a b cl c.
Monad m =>
(a -> b) -> SN m cl b c -> SN m cl a c
^>>> SN m cl2 b c
sn2)
a -> b
f ^>>> Postcompose SN m cl b b1
sn ClSF m (Out cl) b1 c
clsf = SN m cl a b1 -> ClSF m (Out cl) b1 c -> SN m cl a c
forall (m :: Type -> Type) cl a b1 b.
(Clock m (Out cl), Time cl ~ Time (Out cl)) =>
SN m cl a b1 -> ClSF m (Out cl) b1 b -> SN m cl a b
Postcompose (a -> b
f (a -> b) -> SN m cl b b1 -> SN m cl a b1
forall (m :: Type -> Type) a b cl c.
Monad m =>
(a -> b) -> SN m cl b c -> SN m cl a c
^>>> SN m cl b b1
sn) ClSF m (Out cl) b1 c
clsf
a -> b
f ^>>> Precompose ClSF m (In cl) b b1
clsf SN m cl b1 c
sn = ClSF m (In cl) a b1 -> SN m cl b1 c -> SN m cl a c
forall (m :: Type -> Type) cl a b1 b.
(Clock m (In cl), Time cl ~ Time (In cl)) =>
ClSF m (In cl) a b1 -> SN m cl b1 b -> SN m cl a b
Precompose (a -> b
f (a -> b) -> ClSF m (In cl) b b1 -> ClSF m (In cl) a b1
forall (a :: Type -> Type -> Type) b c d.
Arrow a =>
(b -> c) -> a c d -> a b d
^>> ClSF m (In cl) b b1
clsf) SN m cl b1 c
sn
a -> b
f ^>>> Feedback ResBuf m (Out cl) (In cl) d c
buf SN m cl (b, c) (c, d)
sn = ResBuf m (Out cl) (In cl) d c
-> SN m cl (a, c) (c, d) -> SN m cl a c
forall (m :: Type -> Type) cl d c a b.
(Clock m (In cl), Clock m (Out cl), Time (In cl) ~ Time cl,
Time (Out cl) ~ Time cl) =>
ResBuf m (Out cl) (In cl) d c
-> SN m cl (a, c) (b, d) -> SN m cl a b
Feedback ResBuf m (Out cl) (In cl) d c
buf (SN m cl (a, c) (c, d) -> SN m cl a c)
-> SN m cl (a, c) (c, d) -> SN m cl a c
forall a b. (a -> b) -> a -> b
$ (a -> b) -> (a, c) -> (b, c)
forall b c d. (b -> c) -> (b, d) -> (c, d)
forall (a :: Type -> Type -> Type) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first a -> b
f ((a, c) -> (b, c))
-> SN m cl (b, c) (c, d) -> SN m cl (a, c) (c, d)
forall (m :: Type -> Type) a b cl c.
Monad m =>
(a -> b) -> SN m cl b c -> SN m cl a c
^>>> SN m cl (b, c) (c, d)
sn
a -> b
f ^>>> firstResampling :: SN m cl b c
firstResampling@(FirstResampling SN m cl a1 b1
_ ResamplingBuffer m (In cl) (Out cl) c d
_) = ClSF m (In cl) a b -> SN m cl b c -> SN m cl a c
forall (m :: Type -> Type) cl a b1 b.
(Clock m (In cl), Time cl ~ Time (In cl)) =>
ClSF m (In cl) a b1 -> SN m cl b1 b -> SN m cl a b
Precompose ((a -> b) -> ClSF m (In cl) a b
forall b c.
(b -> c) -> Automaton (ReaderT (TimeInfo (In cl)) m) b c
forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr a -> b
f) SN m cl b c
firstResampling
(>--^)
:: ( Clock m (Out cl)
, Time cl ~ Time (Out cl)
)
=> SN m cl a b
-> ClSF m (Out cl) b c
-> SN m cl a c
>--^ :: forall (m :: Type -> Type) cl a b1 b.
(Clock m (Out cl), Time cl ~ Time (Out cl)) =>
SN m cl a b1 -> ClSF m (Out cl) b1 b -> SN m cl a b
(>--^) = SN m cl a b -> ClSF m (Out cl) b c -> SN m cl a c
forall (m :: Type -> Type) cl a b1 b.
(Clock m (Out cl), Time cl ~ Time (Out cl)) =>
SN m cl a b1 -> ClSF m (Out cl) b1 b -> SN m cl a b
Postcompose
(^-->)
:: ( Clock m (In cl)
, Time cl ~ Time (In cl)
)
=> ClSF m (In cl) a b
-> SN m cl b c
-> SN m cl a c
^--> :: forall (m :: Type -> Type) cl a b1 b.
(Clock m (In cl), Time cl ~ Time (In cl)) =>
ClSF m (In cl) a b1 -> SN m cl b1 b -> SN m cl a b
(^-->) = ClSF m (In cl) a b -> SN m cl b c -> SN m cl a c
forall (m :: Type -> Type) cl a b1 b.
(Clock m (In cl), Time cl ~ Time (In cl)) =>
ClSF m (In cl) a b1 -> SN m cl b1 b -> SN m cl a b
Precompose
(****)
:: Monad m
=> SN m cl a b
-> SN m cl c d
-> SN m cl (a, c) (b, d)
Synchronous ClSF m cl a b
clsf1 **** :: forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** Synchronous ClSF m cl c d
clsf2 = ClSF m cl (a, c) (b, d) -> SN m cl (a, c) (b, d)
forall cl (m :: Type -> Type) a b.
(cl ~ In cl, cl ~ Out cl) =>
ClSF m cl a b -> SN m cl a b
Synchronous (ClSF m cl (a, c) (b, d) -> SN m cl (a, c) (b, d))
-> ClSF m cl (a, c) (b, d) -> SN m cl (a, c) (b, d)
forall a b. (a -> b) -> a -> b
$ ClSF m cl a b
clsf1 ClSF m cl a b -> ClSF m cl c d -> ClSF m cl (a, c) (b, d)
forall b c b' c'.
Automaton (ReaderT (TimeInfo cl) m) b c
-> Automaton (ReaderT (TimeInfo cl) m) b' c'
-> Automaton (ReaderT (TimeInfo cl) m) (b, b') (c, c')
forall (a :: Type -> Type -> Type) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** ClSF m cl c d
clsf2
Sequential SN m clab a b1
sn11 ResamplingBuffer m (Out clab) (In clcd) b1 c
rb1 SN m clcd c b
sn12 **** Sequential SN m clab c b1
sn21 ResamplingBuffer m (Out clab) (In clcd) b1 c
rb2 SN m clcd c d
sn22 = SN m clab (a, c) (b1, b1)
-> ResamplingBuffer m (Out clab) (In clcd) (b1, b1) (c, c)
-> SN m clcd (c, c) (b, d)
-> SN m (SequentialClock clab clcd) (a, c) (b, d)
forall (m :: Type -> Type) clab clcd a b1 c b.
(Clock m clab, Clock m clcd, Clock m (Out clab),
Clock m (Out clcd), Clock m (In clab), Clock m (In clcd),
GetClockProxy clab, GetClockProxy clcd, Time clab ~ Time clcd,
Time clab ~ Time (Out clab), Time clcd ~ Time (In clcd)) =>
SN m clab a b1
-> ResamplingBuffer m (Out clab) (In clcd) b1 c
-> SN m clcd c b
-> SN m (SequentialClock clab clcd) a b
Sequential SN m clab (a, c) (b1, b1)
sn1 ResamplingBuffer m (Out clab) (In clcd) (b1, b1) (c, c)
rb SN m clcd (c, c) (b, d)
sn2
where
sn1 :: SN m clab (a, c) (b1, b1)
sn1 = SN m clab a b1
sn11 SN m clab a b1 -> SN m clab c b1 -> SN m clab (a, c) (b1, b1)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m clab c b1
SN m clab c b1
sn21
sn2 :: SN m clcd (c, c) (b, d)
sn2 = SN m clcd c b
sn12 SN m clcd c b -> SN m clcd c d -> SN m clcd (c, c) (b, d)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m clcd c d
SN m clcd c d
sn22
rb :: ResamplingBuffer m (Out clab) (In clcd) (b1, b1) (c, c)
rb = ResamplingBuffer m (Out clab) (In clcd) b1 c
rb1 ResamplingBuffer m (Out clab) (In clcd) b1 c
-> ResamplingBuffer m (Out clab) (In clcd) b1 c
-> ResamplingBuffer m (Out clab) (In clcd) (b1, b1) (c, c)
forall (m :: Type -> Type) cl1 cl2 a b c d.
Monad m =>
ResamplingBuffer m cl1 cl2 a b
-> ResamplingBuffer m cl1 cl2 c d
-> ResamplingBuffer m cl1 cl2 (a, c) (b, d)
*-* ResamplingBuffer m (Out clab) (In clcd) b1 c
ResamplingBuffer m (Out clab) (In clcd) b1 c
rb2
Parallel SN m cl1 a b
sn11 SN m cl2 a b
sn12 **** Parallel SN m cl1 c d
sn21 SN m cl2 c d
sn22 =
SN m cl1 (a, c) (b, d)
-> SN m cl2 (a, c) (b, d)
-> SN m (ParallelClock cl1 cl2) (a, c) (b, d)
forall (m :: Type -> Type) cl1 cl2 a b.
(Clock m cl1, Clock m cl2, Clock m (Out cl1), Clock m (Out cl2),
GetClockProxy cl1, GetClockProxy cl2, Time cl1 ~ Time (Out cl1),
Time cl2 ~ Time (Out cl2), Time cl1 ~ Time cl2,
Time cl1 ~ Time (In cl1), Time cl2 ~ Time (In cl2)) =>
SN m cl1 a b -> SN m cl2 a b -> SN m (ParallelClock cl1 cl2) a b
Parallel (SN m cl1 a b
sn11 SN m cl1 a b -> SN m cl1 c d -> SN m cl1 (a, c) (b, d)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m cl1 c d
SN m cl1 c d
sn21) (SN m cl2 a b
sn12 SN m cl2 a b -> SN m cl2 c d -> SN m cl2 (a, c) (b, d)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m cl2 c d
SN m cl2 c d
sn22)
Precompose ClSF m (In cl) a b1
clsf SN m cl b1 b
sn1 **** SN m cl c d
sn2 = ClSF m (In cl) (a, c) (b1, c)
-> SN m cl (b1, c) (b, d) -> SN m cl (a, c) (b, d)
forall (m :: Type -> Type) cl a b1 b.
(Clock m (In cl), Time cl ~ Time (In cl)) =>
ClSF m (In cl) a b1 -> SN m cl b1 b -> SN m cl a b
Precompose (ClSF m (In cl) a b1 -> ClSF m (In cl) (a, c) (b1, c)
forall b c d.
Automaton (ReaderT (TimeInfo (In cl)) m) b c
-> Automaton (ReaderT (TimeInfo (In cl)) m) (b, d) (c, d)
forall (a :: Type -> Type -> Type) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first ClSF m (In cl) a b1
clsf) (SN m cl (b1, c) (b, d) -> SN m cl (a, c) (b, d))
-> SN m cl (b1, c) (b, d) -> SN m cl (a, c) (b, d)
forall a b. (a -> b) -> a -> b
$ SN m cl b1 b
sn1 SN m cl b1 b -> SN m cl c d -> SN m cl (b1, c) (b, d)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m cl c d
sn2
SN m cl a b
sn1 **** Precompose ClSF m (In cl) c b1
clsf SN m cl b1 d
sn2 = ClSF m (In cl) (a, c) (a, b1)
-> SN m cl (a, b1) (b, d) -> SN m cl (a, c) (b, d)
forall (m :: Type -> Type) cl a b1 b.
(Clock m (In cl), Time cl ~ Time (In cl)) =>
ClSF m (In cl) a b1 -> SN m cl b1 b -> SN m cl a b
Precompose (ClSF m (In cl) c b1 -> ClSF m (In cl) (a, c) (a, b1)
forall b c d.
Automaton (ReaderT (TimeInfo (In cl)) m) b c
-> Automaton (ReaderT (TimeInfo (In cl)) m) (d, b) (d, c)
forall (a :: Type -> Type -> Type) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second ClSF m (In cl) c b1
clsf) (SN m cl (a, b1) (b, d) -> SN m cl (a, c) (b, d))
-> SN m cl (a, b1) (b, d) -> SN m cl (a, c) (b, d)
forall a b. (a -> b) -> a -> b
$ SN m cl a b
sn1 SN m cl a b -> SN m cl b1 d -> SN m cl (a, b1) (b, d)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m cl b1 d
sn2
Postcompose SN m cl a b1
sn1 ClSF m (Out cl) b1 b
clsf **** SN m cl c d
sn2 = SN m cl (a, c) (b1, d)
-> ClSF m (Out cl) (b1, d) (b, d) -> SN m cl (a, c) (b, d)
forall (m :: Type -> Type) cl a b1 b.
(Clock m (Out cl), Time cl ~ Time (Out cl)) =>
SN m cl a b1 -> ClSF m (Out cl) b1 b -> SN m cl a b
Postcompose (SN m cl a b1
sn1 SN m cl a b1 -> SN m cl c d -> SN m cl (a, c) (b1, d)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m cl c d
sn2) (ClSF m (Out cl) b1 b -> ClSF m (Out cl) (b1, d) (b, d)
forall b c d.
Automaton (ReaderT (TimeInfo (Out cl)) m) b c
-> Automaton (ReaderT (TimeInfo (Out cl)) m) (b, d) (c, d)
forall (a :: Type -> Type -> Type) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first ClSF m (Out cl) b1 b
clsf)
SN m cl a b
sn1 **** Postcompose SN m cl c b1
sn2 ClSF m (Out cl) b1 d
clsf = SN m cl (a, c) (b, b1)
-> ClSF m (Out cl) (b, b1) (b, d) -> SN m cl (a, c) (b, d)
forall (m :: Type -> Type) cl a b1 b.
(Clock m (Out cl), Time cl ~ Time (Out cl)) =>
SN m cl a b1 -> ClSF m (Out cl) b1 b -> SN m cl a b
Postcompose (SN m cl a b
sn1 SN m cl a b -> SN m cl c b1 -> SN m cl (a, c) (b, b1)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m cl c b1
sn2) (ClSF m (Out cl) b1 d -> ClSF m (Out cl) (b, b1) (b, d)
forall b c d.
Automaton (ReaderT (TimeInfo (Out cl)) m) b c
-> Automaton (ReaderT (TimeInfo (Out cl)) m) (d, b) (d, c)
forall (a :: Type -> Type -> Type) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second ClSF m (Out cl) b1 d
clsf)
Feedback ResBuf m (Out cl) (In cl) d c
buf SN m cl (a, c) (b, d)
sn1 **** SN m cl c d
sn2 = ResBuf m (Out cl) (In cl) d c
-> SN m cl ((a, c), c) ((b, d), d) -> SN m cl (a, c) (b, d)
forall (m :: Type -> Type) cl d c a b.
(Clock m (In cl), Clock m (Out cl), Time (In cl) ~ Time cl,
Time (Out cl) ~ Time cl) =>
ResBuf m (Out cl) (In cl) d c
-> SN m cl (a, c) (b, d) -> SN m cl a b
Feedback ResBuf m (Out cl) (In cl) d c
buf (SN m cl ((a, c), c) ((b, d), d) -> SN m cl (a, c) (b, d))
-> SN m cl ((a, c), c) ((b, d), d) -> SN m cl (a, c) (b, d)
forall a b. (a -> b) -> a -> b
$ (\((a
a, c
c), c
c1) -> ((a
a, c
c1), c
c)) (((a, c), c) -> ((a, c), c))
-> SN m cl ((a, c), c) ((b, d), d)
-> SN m cl ((a, c), c) ((b, d), d)
forall (m :: Type -> Type) a b cl c.
Monad m =>
(a -> b) -> SN m cl b c -> SN m cl a c
^>>> (SN m cl (a, c) (b, d)
sn1 SN m cl (a, c) (b, d)
-> SN m cl c d -> SN m cl ((a, c), c) ((b, d), d)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m cl c d
sn2) SN m cl ((a, c), c) ((b, d), d)
-> (((b, d), d) -> ((b, d), d)) -> SN m cl ((a, c), c) ((b, d), d)
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ (\((b
b, d
d1), d
d) -> ((b
b, d
d), d
d1))
SN m cl a b
sn1 **** Feedback ResBuf m (Out cl) (In cl) d c
buf SN m cl (c, c) (d, d)
sn2 = ResBuf m (Out cl) (In cl) d c
-> SN m cl ((a, c), c) ((b, d), d) -> SN m cl (a, c) (b, d)
forall (m :: Type -> Type) cl d c a b.
(Clock m (In cl), Clock m (Out cl), Time (In cl) ~ Time cl,
Time (Out cl) ~ Time cl) =>
ResBuf m (Out cl) (In cl) d c
-> SN m cl (a, c) (b, d) -> SN m cl a b
Feedback ResBuf m (Out cl) (In cl) d c
buf (SN m cl ((a, c), c) ((b, d), d) -> SN m cl (a, c) (b, d))
-> SN m cl ((a, c), c) ((b, d), d) -> SN m cl (a, c) (b, d)
forall a b. (a -> b) -> a -> b
$ (\((a
a, c
c), c
c1) -> (a
a, (c
c, c
c1))) (((a, c), c) -> (a, (c, c)))
-> SN m cl (a, (c, c)) (b, (d, d))
-> SN m cl ((a, c), c) (b, (d, d))
forall (m :: Type -> Type) a b cl c.
Monad m =>
(a -> b) -> SN m cl b c -> SN m cl a c
^>>> (SN m cl a b
sn1 SN m cl a b
-> SN m cl (c, c) (d, d) -> SN m cl (a, (c, c)) (b, (d, d))
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m cl (c, c) (d, d)
sn2) SN m cl ((a, c), c) (b, (d, d))
-> ((b, (d, d)) -> ((b, d), d)) -> SN m cl ((a, c), c) ((b, d), d)
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ (\(b
b, (d
d, d
d1)) -> ((b
b, d
d), d
d1))
FirstResampling SN m cl a1 b1
sn1 ResamplingBuffer m (In cl) (Out cl) c d
buf **** SN m cl c d
sn2 = (\((a1
a1, c
c1), c
c) -> ((a1
a1, c
c), c
c1)) ((a, c) -> ((a1, c), c))
-> SN m cl ((a1, c), c) ((b1, d), d) -> SN m cl (a, c) ((b1, d), d)
forall (m :: Type -> Type) a b cl c.
Monad m =>
(a -> b) -> SN m cl b c -> SN m cl a c
^>>> SN m cl (a1, c) (b1, d)
-> ResamplingBuffer m (In cl) (Out cl) c d
-> SN m cl ((a1, c), c) ((b1, d), d)
forall (m :: Type -> Type) cl a1 b1 c d.
(Clock m (In cl), Clock m (Out cl), Time cl ~ Time (Out cl),
Time cl ~ Time (In cl)) =>
SN m cl a1 b1
-> ResamplingBuffer m (In cl) (Out cl) c d
-> SN m cl (a1, c) (b1, d)
FirstResampling (SN m cl a1 b1
sn1 SN m cl a1 b1 -> SN m cl c d -> SN m cl (a1, c) (b1, d)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m cl c d
sn2) ResamplingBuffer m (In cl) (Out cl) c d
buf SN m cl (a, c) ((b1, d), d)
-> (((b1, d), d) -> (b, d)) -> SN m cl (a, c) (b, d)
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ (\((b1
b1, d
d), d
d1) -> ((b1
b1, d
d1), d
d))
SN m cl a b
sn1 **** FirstResampling SN m cl a1 b1
sn2 ResamplingBuffer m (In cl) (Out cl) c d
buf = (\(a
a, (a1
a1, c
c1)) -> ((a
a, a1
a1), c
c1)) ((a, c) -> ((a, a1), c))
-> SN m cl ((a, a1), c) ((b, b1), d) -> SN m cl (a, c) ((b, b1), d)
forall (m :: Type -> Type) a b cl c.
Monad m =>
(a -> b) -> SN m cl b c -> SN m cl a c
^>>> SN m cl (a, a1) (b, b1)
-> ResamplingBuffer m (In cl) (Out cl) c d
-> SN m cl ((a, a1), c) ((b, b1), d)
forall (m :: Type -> Type) cl a1 b1 c d.
(Clock m (In cl), Clock m (Out cl), Time cl ~ Time (Out cl),
Time cl ~ Time (In cl)) =>
SN m cl a1 b1
-> ResamplingBuffer m (In cl) (Out cl) c d
-> SN m cl (a1, c) (b1, d)
FirstResampling (SN m cl a b
sn1 SN m cl a b -> SN m cl a1 b1 -> SN m cl (a, a1) (b, b1)
forall (m :: Type -> Type) cl a b c d.
Monad m =>
SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
**** SN m cl a1 b1
sn2) ResamplingBuffer m (In cl) (Out cl) c d
buf SN m cl (a, c) ((b, b1), d)
-> (((b, b1), d) -> (b, d)) -> SN m cl (a, c) (b, d)
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ (\((b
b, b1
b1), d
d1) -> (b
b, (b1
b1, d
d1)))
Synchronous ClSF m cl a b
_ **** Parallel SN m cl1 c d
_ SN m cl2 c d
_ = [Char] -> SN m cl (a, c) (b, d)
forall a. HasCallStack => [Char] -> a
error [Char]
"Impossible pattern: Synchronous _ **** Parallel _ _"
Parallel SN m cl1 a b
_ SN m cl2 a b
_ **** Synchronous ClSF m cl c d
_ = [Char] -> SN m cl (a, c) (b, d)
forall a. HasCallStack => [Char] -> a
error [Char]
"Impossible pattern: Parallel _ _ **** Synchronous _"
Synchronous ClSF m cl a b
_ **** Sequential {} = [Char] -> SN m cl (a, c) (b, d)
forall a. HasCallStack => [Char] -> a
error [Char]
"Impossible pattern: Synchronous _ **** Sequential {}"
Sequential {} **** Synchronous ClSF m cl c d
_ = [Char] -> SN m cl (a, c) (b, d)
forall a. HasCallStack => [Char] -> a
error [Char]
"Impossible pattern: Sequential {} **** Synchronous _"
(||||)
:: ( Monad m, Clock m clL, Clock m clR
, Clock m (Out clL), Clock m (Out clR)
, GetClockProxy clL, GetClockProxy clR
, Time clL ~ Time clR
, Time clL ~ Time (Out clL), Time clL ~ Time (In clL)
, Time clR ~ Time (Out clR), Time clR ~ Time (In clR)
)
=> SN m clL a b
-> SN m clR a b
-> SN m (ParClock clL clR) a b
|||| :: forall (m :: Type -> Type) clL clR a b.
(Monad m, Clock m clL, Clock m clR, Clock m (Out clL),
Clock m (Out clR), GetClockProxy clL, GetClockProxy clR,
Time clL ~ Time clR, Time clL ~ Time (Out clL),
Time clL ~ Time (In clL), Time clR ~ Time (Out clR),
Time clR ~ Time (In clR)) =>
SN m clL a b -> SN m clR a b -> SN m (ParClock clL clR) a b
(||||) = SN m clL a b -> SN m clR a b -> SN m (ParallelClock clL clR) a b
forall (m :: Type -> Type) cl1 cl2 a b.
(Clock m cl1, Clock m cl2, Clock m (Out cl1), Clock m (Out cl2),
GetClockProxy cl1, GetClockProxy cl2, Time cl1 ~ Time (Out cl1),
Time cl2 ~ Time (Out cl2), Time cl1 ~ Time cl2,
Time cl1 ~ Time (In cl1), Time cl2 ~ Time (In cl2)) =>
SN m cl1 a b -> SN m cl2 a b -> SN m (ParallelClock cl1 cl2) a b
Parallel
(++++)
:: ( Monad m, Clock m clL, Clock m clR
, Clock m (Out clL), Clock m (Out clR)
, GetClockProxy clL, GetClockProxy clR
, Time clL ~ Time clR
, Time clL ~ Time (Out clL), Time clL ~ Time (In clL)
, Time clR ~ Time (Out clR), Time clR ~ Time (In clR)
)
=> SN m clL a b
-> SN m clR a c
-> SN m (ParClock clL clR) a (Either b c)
SN m clL a b
snL ++++ :: forall (m :: Type -> Type) clL clR a b c.
(Monad m, Clock m clL, Clock m clR, Clock m (Out clL),
Clock m (Out clR), GetClockProxy clL, GetClockProxy clR,
Time clL ~ Time clR, Time clL ~ Time (Out clL),
Time clL ~ Time (In clL), Time clR ~ Time (Out clR),
Time clR ~ Time (In clR)) =>
SN m clL a b
-> SN m clR a c -> SN m (ParClock clL clR) a (Either b c)
++++ SN m clR a c
snR = (SN m clL a b
snL SN m clL a b -> (b -> Either b c) -> SN m clL a (Either b c)
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ b -> Either b c
forall a b. a -> Either a b
Left) SN m clL a (Either b c)
-> SN m clR a (Either b c)
-> SN m (ParClock clL clR) a (Either b c)
forall (m :: Type -> Type) clL clR a b.
(Monad m, Clock m clL, Clock m clR, Clock m (Out clL),
Clock m (Out clR), GetClockProxy clL, GetClockProxy clR,
Time clL ~ Time clR, Time clL ~ Time (Out clL),
Time clL ~ Time (In clL), Time clR ~ Time (Out clR),
Time clR ~ Time (In clR)) =>
SN m clL a b -> SN m clR a b -> SN m (ParClock clL clR) a b
|||| (SN m clR a c
snR SN m clR a c -> (c -> Either b c) -> SN m clR a (Either b c)
forall (m :: Type -> Type) cl a b c.
Monad m =>
SN m cl a b -> (b -> c) -> SN m cl a c
>>>^ c -> Either b c
forall a b. b -> Either a b
Right)