{-# LANGUAGE Rank2Types #-}
module FRP.Yampa.Switches
(
switch, dSwitch
, rSwitch, drSwitch
, kSwitch, dkSwitch
, parB
, pSwitchB, dpSwitchB
, rpSwitchB, drpSwitchB
, par
, pSwitch, dpSwitch
, rpSwitch, drpSwitch
, parZ
, pSwitchZ
, dpSwitchZ
, rpSwitchZ
, drpSwitchZ
, parC
)
where
import Control.Arrow (arr, first)
import FRP.Yampa.Basic (constant, (>=-))
import FRP.Yampa.Diagnostics (usrErr)
import FRP.Yampa.Event (Event (..), noEventSnd)
import FRP.Yampa.InternalCore (DTime, FunDesc (..), SF (..), SF' (..), fdFun,
sfArrG, sfConst, sfTF')
switch :: SF a (b, Event c) -> (c -> SF a b) -> SF a b
switch :: forall a b c. SF a (b, Event c) -> (c -> SF a b) -> SF a b
switch (SF {sfTF :: forall a b. SF a b -> a -> Transition a b
sfTF = a -> Transition a (b, Event c)
tf10}) c -> SF a b
k = SF {sfTF :: a -> Transition a b
sfTF = a -> Transition a b
tf0}
where
tf0 :: a -> Transition a b
tf0 a
a0 =
case a -> Transition a (b, Event c)
tf10 a
a0 of
(SF' a (b, Event c)
sf1, (b
b0, Event c
NoEvent)) -> (forall a b c. SF' a (b, Event c) -> (c -> SF a b) -> SF' a b
switchAux SF' a (b, Event c)
sf1 c -> SF a b
k, b
b0)
(SF' a (b, Event c)
_, (b
_, Event c
c0)) -> forall a b. SF a b -> a -> Transition a b
sfTF (c -> SF a b
k c
c0) a
a0
switchAux :: SF' a (b, Event c) -> (c -> SF a b) -> SF' a b
switchAux :: forall a b c. SF' a (b, Event c) -> (c -> SF a b) -> SF' a b
switchAux (SFArr DTime -> a -> Transition a (b, Event c)
_ (FDC (b
b, Event c
NoEvent))) c -> SF a b
_ = forall b a. b -> SF' a b
sfConst b
b
switchAux (SFArr DTime -> a -> Transition a (b, Event c)
_ FunDesc a (b, Event c)
fd1) c -> SF a b
k = forall a b c. (a -> (b, Event c)) -> (c -> SF a b) -> SF' a b
switchAuxA1 (forall a b. FunDesc a b -> a -> b
fdFun FunDesc a (b, Event c)
fd1) c -> SF a b
k
switchAux SF' a (b, Event c)
sf1 c -> SF a b
k = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> (SF' a b, b)
tf
where
tf :: DTime -> a -> (SF' a b, b)
tf DTime
dt a
a =
case (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' a (b, Event c)
sf1) DTime
dt a
a of
(SF' a (b, Event c)
sf1', (b
b, Event c
NoEvent)) -> (forall a b c. SF' a (b, Event c) -> (c -> SF a b) -> SF' a b
switchAux SF' a (b, Event c)
sf1' c -> SF a b
k, b
b)
(SF' a (b, Event c)
_, (b
_, Event c
c)) -> forall a b. SF a b -> a -> Transition a b
sfTF (c -> SF a b
k c
c) a
a
switchAuxA1 :: (a -> (b, Event c)) -> (c -> SF a b) -> SF' a b
switchAuxA1 :: forall a b c. (a -> (b, Event c)) -> (c -> SF a b) -> SF' a b
switchAuxA1 a -> (b, Event c)
f1 c -> SF a b
k = SF' a b
sf
where
sf :: SF' a b
sf = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> Transition a b
tf
tf :: DTime -> a -> Transition a b
tf DTime
_ a
a =
case a -> (b, Event c)
f1 a
a of
(b
b, Event c
NoEvent) -> (SF' a b
sf, b
b)
(b
_, Event c
c) -> forall a b. SF a b -> a -> Transition a b
sfTF (c -> SF a b
k c
c) a
a
dSwitch :: SF a (b, Event c) -> (c -> SF a b) -> SF a b
dSwitch :: forall a b c. SF a (b, Event c) -> (c -> SF a b) -> SF a b
dSwitch (SF {sfTF :: forall a b. SF a b -> a -> Transition a b
sfTF = a -> Transition a (b, Event c)
tf10}) c -> SF a b
k = SF {sfTF :: a -> Transition a b
sfTF = a -> Transition a b
tf0}
where
tf0 :: a -> Transition a b
tf0 a
a0 = ( case Event c
ec0 of
Event c
NoEvent -> forall a b c. SF' a (b, Event c) -> (c -> SF a b) -> SF' a b
dSwitchAux SF' a (b, Event c)
sf1 c -> SF a b
k
Event c
c0 -> forall a b. (a, b) -> a
fst (forall a b. SF a b -> a -> Transition a b
sfTF (c -> SF a b
k c
c0) a
a0)
, b
b0
)
where
(SF' a (b, Event c)
sf1, (b
b0, Event c
ec0)) = a -> Transition a (b, Event c)
tf10 a
a0
dSwitchAux :: SF' a (b, Event c) -> (c -> SF a b) -> SF' a b
dSwitchAux :: forall a b c. SF' a (b, Event c) -> (c -> SF a b) -> SF' a b
dSwitchAux (SFArr DTime -> a -> Transition a (b, Event c)
_ (FDC (b
b, Event c
NoEvent))) c -> SF a b
_ = forall b a. b -> SF' a b
sfConst b
b
dSwitchAux (SFArr DTime -> a -> Transition a (b, Event c)
_ FunDesc a (b, Event c)
fd1) c -> SF a b
k = forall a b c. (a -> (b, Event c)) -> (c -> SF a b) -> SF' a b
dSwitchAuxA1 (forall a b. FunDesc a b -> a -> b
fdFun FunDesc a (b, Event c)
fd1) c -> SF a b
k
dSwitchAux SF' a (b, Event c)
sf1 c -> SF a b
k = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> (SF' a b, b)
tf
where
tf :: DTime -> a -> (SF' a b, b)
tf DTime
dt a
a = ( case Event c
ec of
Event c
NoEvent -> forall a b c. SF' a (b, Event c) -> (c -> SF a b) -> SF' a b
dSwitchAux SF' a (b, Event c)
sf1' c -> SF a b
k
Event c
c -> forall a b. (a, b) -> a
fst (forall a b. SF a b -> a -> Transition a b
sfTF (c -> SF a b
k c
c) a
a)
, b
b
)
where
(SF' a (b, Event c)
sf1', (b
b, Event c
ec)) = (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' a (b, Event c)
sf1) DTime
dt a
a
dSwitchAuxA1 :: (a -> (b, Event c)) -> (c -> SF a b) -> SF' a b
dSwitchAuxA1 :: forall a b c. (a -> (b, Event c)) -> (c -> SF a b) -> SF' a b
dSwitchAuxA1 a -> (b, Event c)
f1 c -> SF a b
k = SF' a b
sf
where
sf :: SF' a b
sf = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> Transition a b
tf
tf :: DTime -> a -> Transition a b
tf DTime
_ a
a = ( case Event c
ec of
Event c
NoEvent -> SF' a b
sf
Event c
c -> forall a b. (a, b) -> a
fst (forall a b. SF a b -> a -> Transition a b
sfTF (c -> SF a b
k c
c) a
a)
, b
b
)
where
(b
b, Event c
ec) = a -> (b, Event c)
f1 a
a
rSwitch :: SF a b -> SF (a, Event (SF a b)) b
rSwitch :: forall a b. SF a b -> SF (a, Event (SF a b)) b
rSwitch SF a b
sf = forall a b c. SF a (b, Event c) -> (c -> SF a b) -> SF a b
switch (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first SF a b
sf) ((forall a b c. (a, Event b) -> (a, Event c)
noEventSnd forall a b. (a -> a) -> SF a b -> SF a b
>=-) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. SF a b -> SF (a, Event (SF a b)) b
rSwitch)
drSwitch :: SF a b -> SF (a, Event (SF a b)) b
drSwitch :: forall a b. SF a b -> SF (a, Event (SF a b)) b
drSwitch SF a b
sf = forall a b c. SF a (b, Event c) -> (c -> SF a b) -> SF a b
dSwitch (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first SF a b
sf) ((forall a b c. (a, Event b) -> (a, Event c)
noEventSnd forall a b. (a -> a) -> SF a b -> SF a b
>=-) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. SF a b -> SF (a, Event (SF a b)) b
drSwitch)
kSwitch :: SF a b -> SF (a, b) (Event c) -> (SF a b -> c -> SF a b) -> SF a b
kSwitch :: forall a b c.
SF a b -> SF (a, b) (Event c) -> (SF a b -> c -> SF a b) -> SF a b
kSwitch sf10 :: SF a b
sf10@(SF {sfTF :: forall a b. SF a b -> a -> Transition a b
sfTF = a -> Transition a b
tf10}) (SF {sfTF :: forall a b. SF a b -> a -> Transition a b
sfTF = (a, b) -> Transition (a, b) (Event c)
tfe0}) SF a b -> c -> SF a b
k = SF {sfTF :: a -> Transition a b
sfTF = a -> Transition a b
tf0}
where
tf0 :: a -> Transition a b
tf0 a
a0 = case (a, b) -> Transition (a, b) (Event c)
tfe0 (a
a0, b
b0) of
(SF' (a, b) (Event c)
sfe, Event c
NoEvent) -> (SF' a b -> SF' (a, b) (Event c) -> SF' a b
kSwitchAux SF' a b
sf1 SF' (a, b) (Event c)
sfe, b
b0)
(SF' (a, b) (Event c)
_, Event c
c0) -> forall a b. SF a b -> a -> Transition a b
sfTF (SF a b -> c -> SF a b
k SF a b
sf10 c
c0) a
a0
where
(SF' a b
sf1, b
b0) = a -> Transition a b
tf10 a
a0
kSwitchAux :: SF' a b -> SF' (a, b) (Event c) -> SF' a b
kSwitchAux (SFArr DTime -> a -> Transition a b
_ (FDC b
b)) SF' (a, b) (Event c)
sfe = b -> SF' (a, b) (Event c) -> SF' a b
kSwitchAuxC1 b
b SF' (a, b) (Event c)
sfe
kSwitchAux (SFArr DTime -> a -> Transition a b
_ FunDesc a b
fd1) SF' (a, b) (Event c)
sfe = (a -> b) -> SF' (a, b) (Event c) -> SF' a b
kSwitchAuxA1 (forall a b. FunDesc a b -> a -> b
fdFun FunDesc a b
fd1) SF' (a, b) (Event c)
sfe
kSwitchAux SF' a b
sf1 (SFArr DTime -> (a, b) -> Transition (a, b) (Event c)
_ (FDC Event c
NoEvent)) = SF' a b
sf1
kSwitchAux SF' a b
sf1 (SFArr DTime -> (a, b) -> Transition (a, b) (Event c)
_ FunDesc (a, b) (Event c)
fde) = SF' a b -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxAE SF' a b
sf1 (forall a b. FunDesc a b -> a -> b
fdFun FunDesc (a, b) (Event c)
fde)
kSwitchAux SF' a b
sf1 SF' (a, b) (Event c)
sfe = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> Transition a b
tf
where
tf :: DTime -> a -> Transition a b
tf DTime
dt a
a = case (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' (a, b) (Event c)
sfe) DTime
dt (a
a, b
b) of
(SF' (a, b) (Event c)
sfe', Event c
NoEvent) -> (SF' a b -> SF' (a, b) (Event c) -> SF' a b
kSwitchAux SF' a b
sf1' SF' (a, b) (Event c)
sfe', b
b)
(SF' (a, b) (Event c)
_, Event c
c) -> forall a b. SF a b -> a -> Transition a b
sfTF (SF a b -> c -> SF a b
k (forall a b. SF' a b -> DTime -> SF a b
freeze SF' a b
sf1 DTime
dt) c
c) a
a
where
(SF' a b
sf1', b
b) = (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' a b
sf1) DTime
dt a
a
kSwitchAuxC1 :: b -> SF' (a, b) (Event c) -> SF' a b
kSwitchAuxC1 b
b (SFArr DTime -> (a, b) -> Transition (a, b) (Event c)
_ (FDC Event c
NoEvent)) = forall b a. b -> SF' a b
sfConst b
b
kSwitchAuxC1 b
b (SFArr DTime -> (a, b) -> Transition (a, b) (Event c)
_ FunDesc (a, b) (Event c)
fde) = b -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxC1AE b
b (forall a b. FunDesc a b -> a -> b
fdFun FunDesc (a, b) (Event c)
fde)
kSwitchAuxC1 b
b SF' (a, b) (Event c)
sfe = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> Transition a b
tf
where
tf :: DTime -> a -> Transition a b
tf DTime
dt a
a =
case (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' (a, b) (Event c)
sfe) DTime
dt (a
a, b
b) of
(SF' (a, b) (Event c)
sfe', Event c
NoEvent) -> (b -> SF' (a, b) (Event c) -> SF' a b
kSwitchAuxC1 b
b SF' (a, b) (Event c)
sfe', b
b)
(SF' (a, b) (Event c)
_, Event c
c) -> forall a b. SF a b -> a -> Transition a b
sfTF (SF a b -> c -> SF a b
k (forall b a. b -> SF a b
constant b
b) c
c) a
a
kSwitchAuxA1 :: (a -> b) -> SF' (a, b) (Event c) -> SF' a b
kSwitchAuxA1 a -> b
f1 (SFArr DTime -> (a, b) -> Transition (a, b) (Event c)
_ (FDC Event c
NoEvent)) = forall a b. (a -> b) -> SF' a b
sfArrG a -> b
f1
kSwitchAuxA1 a -> b
f1 (SFArr DTime -> (a, b) -> Transition (a, b) (Event c)
_ FunDesc (a, b) (Event c)
fde) = (a -> b) -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxA1AE a -> b
f1 (forall a b. FunDesc a b -> a -> b
fdFun FunDesc (a, b) (Event c)
fde)
kSwitchAuxA1 a -> b
f1 SF' (a, b) (Event c)
sfe = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> Transition a b
tf
where
tf :: DTime -> a -> Transition a b
tf DTime
dt a
a = case (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' (a, b) (Event c)
sfe) DTime
dt (a
a, b
b) of
(SF' (a, b) (Event c)
sfe', Event c
NoEvent) -> ((a -> b) -> SF' (a, b) (Event c) -> SF' a b
kSwitchAuxA1 a -> b
f1 SF' (a, b) (Event c)
sfe', b
b)
(SF' (a, b) (Event c)
_, Event c
c) -> forall a b. SF a b -> a -> Transition a b
sfTF (SF a b -> c -> SF a b
k (forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr a -> b
f1) c
c) a
a
where
b :: b
b = a -> b
f1 a
a
kSwitchAuxAE :: SF' a b -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxAE (SFArr DTime -> a -> Transition a b
_ (FDC b
b)) (a, b) -> Event c
fe = b -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxC1AE b
b (a, b) -> Event c
fe
kSwitchAuxAE (SFArr DTime -> a -> Transition a b
_ FunDesc a b
fd1) (a, b) -> Event c
fe = (a -> b) -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxA1AE (forall a b. FunDesc a b -> a -> b
fdFun FunDesc a b
fd1) (a, b) -> Event c
fe
kSwitchAuxAE SF' a b
sf1 (a, b) -> Event c
fe = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> Transition a b
tf
where
tf :: DTime -> a -> Transition a b
tf DTime
dt a
a = case (a, b) -> Event c
fe (a
a, b
b) of
Event c
NoEvent -> (SF' a b -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxAE SF' a b
sf1' (a, b) -> Event c
fe, b
b)
Event c
c -> forall a b. SF a b -> a -> Transition a b
sfTF (SF a b -> c -> SF a b
k (forall a b. SF' a b -> DTime -> SF a b
freeze SF' a b
sf1 DTime
dt) c
c) a
a
where
(SF' a b
sf1', b
b) = (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' a b
sf1) DTime
dt a
a
kSwitchAuxC1AE :: b -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxC1AE b
b (a, b) -> Event c
fe = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' forall {p}. p -> a -> Transition a b
tf
where
tf :: p -> a -> Transition a b
tf p
_ a
a =
case (a, b) -> Event c
fe (a
a, b
b) of
Event c
NoEvent -> (b -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxC1AE b
b (a, b) -> Event c
fe, b
b)
Event c
c -> forall a b. SF a b -> a -> Transition a b
sfTF (SF a b -> c -> SF a b
k (forall b a. b -> SF a b
constant b
b) c
c) a
a
kSwitchAuxA1AE :: (a -> b) -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxA1AE a -> b
f1 (a, b) -> Event c
fe = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' forall {p}. p -> a -> Transition a b
tf
where
tf :: p -> a -> Transition a b
tf p
_ a
a = case (a, b) -> Event c
fe (a
a, b
b) of
Event c
NoEvent -> ((a -> b) -> ((a, b) -> Event c) -> SF' a b
kSwitchAuxA1AE a -> b
f1 (a, b) -> Event c
fe, b
b)
Event c
c -> forall a b. SF a b -> a -> Transition a b
sfTF (SF a b -> c -> SF a b
k (forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr a -> b
f1) c
c) a
a
where
b :: b
b = a -> b
f1 a
a
dkSwitch :: SF a b -> SF (a, b) (Event c) -> (SF a b -> c -> SF a b) -> SF a b
dkSwitch :: forall a b c.
SF a b -> SF (a, b) (Event c) -> (SF a b -> c -> SF a b) -> SF a b
dkSwitch sf10 :: SF a b
sf10@(SF {sfTF :: forall a b. SF a b -> a -> Transition a b
sfTF = a -> Transition a b
tf10}) (SF {sfTF :: forall a b. SF a b -> a -> Transition a b
sfTF = (a, b) -> Transition (a, b) (Event c)
tfe0}) SF a b -> c -> SF a b
k = SF {sfTF :: a -> Transition a b
sfTF = a -> Transition a b
tf0}
where
tf0 :: a -> Transition a b
tf0 a
a0 = ( case (a, b) -> Transition (a, b) (Event c)
tfe0 (a
a0, b
b0) of
(SF' (a, b) (Event c)
sfe, Event c
NoEvent) -> SF' a b -> SF' (a, b) (Event c) -> SF' a b
dkSwitchAux SF' a b
sf1 SF' (a, b) (Event c)
sfe
(SF' (a, b) (Event c)
_, Event c
c0) -> forall a b. (a, b) -> a
fst (forall a b. SF a b -> a -> Transition a b
sfTF (SF a b -> c -> SF a b
k SF a b
sf10 c
c0) a
a0)
, b
b0
)
where
(SF' a b
sf1, b
b0) = a -> Transition a b
tf10 a
a0
dkSwitchAux :: SF' a b -> SF' (a, b) (Event c) -> SF' a b
dkSwitchAux SF' a b
sf1 (SFArr DTime -> (a, b) -> Transition (a, b) (Event c)
_ (FDC Event c
NoEvent)) = SF' a b
sf1
dkSwitchAux SF' a b
sf1 SF' (a, b) (Event c)
sfe = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> Transition a b
tf
where
tf :: DTime -> a -> Transition a b
tf DTime
dt a
a = ( case (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' (a, b) (Event c)
sfe) DTime
dt (a
a, b
b) of
(SF' (a, b) (Event c)
sfe', Event c
NoEvent) -> SF' a b -> SF' (a, b) (Event c) -> SF' a b
dkSwitchAux SF' a b
sf1' SF' (a, b) (Event c)
sfe'
(SF' (a, b) (Event c)
_, Event c
c) -> forall a b. (a, b) -> a
fst (forall a b. SF a b -> a -> Transition a b
sfTF (SF a b -> c -> SF a b
k (forall a b. SF' a b -> DTime -> SF a b
freeze SF' a b
sf1 DTime
dt) c
c) a
a)
, b
b
)
where
(SF' a b
sf1', b
b) = (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' a b
sf1) DTime
dt a
a
broadcast :: Functor col => a -> col sf -> col (a, sf)
broadcast :: forall (col :: * -> *) a sf.
Functor col =>
a -> col sf -> col (a, sf)
broadcast a
a = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\sf
sf -> (a
a, sf
sf))
parB :: Functor col => col (SF a b) -> SF a (col b)
parB :: forall (col :: * -> *) a b.
Functor col =>
col (SF a b) -> SF a (col b)
parB = forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c) -> SF a (col c)
par forall (col :: * -> *) a sf.
Functor col =>
a -> col sf -> col (a, sf)
broadcast
pSwitchB :: Functor col
=> col (SF a b)
-> SF (a, col b) (Event c)
-> (col (SF a b) -> c -> SF a (col b))
-> SF a (col b)
pSwitchB :: forall (col :: * -> *) a b c.
Functor col =>
col (SF a b)
-> SF (a, col b) (Event c)
-> (col (SF a b) -> c -> SF a (col b))
-> SF a (col b)
pSwitchB = forall (col :: * -> *) a b c d.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, col c) (Event d)
-> (col (SF b c) -> d -> SF a (col c))
-> SF a (col c)
pSwitch forall (col :: * -> *) a sf.
Functor col =>
a -> col sf -> col (a, sf)
broadcast
dpSwitchB :: Functor col
=> col (SF a b)
-> SF (a, col b) (Event c)
-> (col (SF a b) -> c -> SF a (col b))
-> SF a (col b)
dpSwitchB :: forall (col :: * -> *) a b c.
Functor col =>
col (SF a b)
-> SF (a, col b) (Event c)
-> (col (SF a b) -> c -> SF a (col b))
-> SF a (col b)
dpSwitchB = forall (col :: * -> *) a b c d.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, col c) (Event d)
-> (col (SF b c) -> d -> SF a (col c))
-> SF a (col c)
dpSwitch forall (col :: * -> *) a sf.
Functor col =>
a -> col sf -> col (a, sf)
broadcast
rpSwitchB :: Functor col
=> col (SF a b)
-> SF (a, Event (col (SF a b) -> col (SF a b))) (col b)
rpSwitchB :: forall (col :: * -> *) a b.
Functor col =>
col (SF a b)
-> SF (a, Event (col (SF a b) -> col (SF a b))) (col b)
rpSwitchB = forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, Event (col (SF b c) -> col (SF b c))) (col c)
rpSwitch forall (col :: * -> *) a sf.
Functor col =>
a -> col sf -> col (a, sf)
broadcast
drpSwitchB :: Functor col
=> col (SF a b)
-> SF (a, Event (col (SF a b) -> col (SF a b))) (col b)
drpSwitchB :: forall (col :: * -> *) a b.
Functor col =>
col (SF a b)
-> SF (a, Event (col (SF a b) -> col (SF a b))) (col b)
drpSwitchB = forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, Event (col (SF b c) -> col (SF b c))) (col c)
drpSwitch forall (col :: * -> *) a sf.
Functor col =>
a -> col sf -> col (a, sf)
broadcast
par :: Functor col
=> (forall sf . (a -> col sf -> col (b, sf)))
-> col (SF b c)
-> SF a (col c)
par :: forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c) -> SF a (col c)
par forall sf. a -> col sf -> col (b, sf)
rf col (SF b c)
sfs0 = SF {sfTF :: a -> Transition a (col c)
sfTF = a -> Transition a (col c)
tf0}
where
tf0 :: a -> Transition a (col c)
tf0 a
a0 = (forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF' b c) -> SF' a (col c)
parAux forall sf. a -> col sf -> col (b, sf)
rf col (SF' b c)
sfs, col c
cs0)
where
bsfs0 :: col (b, SF b c)
bsfs0 = forall sf. a -> col sf -> col (b, sf)
rf a
a0 col (SF b c)
sfs0
sfcs0 :: col (Transition b c)
sfcs0 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(b
b0, SF b c
sf0) -> (forall a b. SF a b -> a -> Transition a b
sfTF SF b c
sf0) b
b0) col (b, SF b c)
bsfs0
sfs :: col (SF' b c)
sfs = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> a
fst col (Transition b c)
sfcs0
cs0 :: col c
cs0 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd col (Transition b c)
sfcs0
parAux :: Functor col
=> (forall sf . (a -> col sf -> col (b, sf)))
-> col (SF' b c)
-> SF' a (col c)
parAux :: forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF' b c) -> SF' a (col c)
parAux forall sf. a -> col sf -> col (b, sf)
rf col (SF' b c)
sfs = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> (SF' a (col c), col c)
tf
where
tf :: DTime -> a -> (SF' a (col c), col c)
tf DTime
dt a
a = (forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF' b c) -> SF' a (col c)
parAux forall sf. a -> col sf -> col (b, sf)
rf col (SF' b c)
sfs', col c
cs)
where
bsfs :: col (b, SF' b c)
bsfs = forall sf. a -> col sf -> col (b, sf)
rf a
a col (SF' b c)
sfs
sfcs' :: col (Transition b c)
sfcs' = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(b
b, SF' b c
sf) -> (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' b c
sf) DTime
dt b
b) col (b, SF' b c)
bsfs
sfs' :: col (SF' b c)
sfs' = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> a
fst col (Transition b c)
sfcs'
cs :: col c
cs = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd col (Transition b c)
sfcs'
pSwitch :: Functor col
=> (forall sf . (a -> col sf -> col (b, sf)))
-> col (SF b c)
-> SF (a, col c) (Event d)
-> (col (SF b c) -> d -> SF a (col c))
-> SF a (col c)
pSwitch :: forall (col :: * -> *) a b c d.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, col c) (Event d)
-> (col (SF b c) -> d -> SF a (col c))
-> SF a (col c)
pSwitch forall sf. a -> col sf -> col (b, sf)
rf col (SF b c)
sfs0 SF (a, col c) (Event d)
sfe0 col (SF b c) -> d -> SF a (col c)
k = SF {sfTF :: a -> Transition a (col c)
sfTF = a -> Transition a (col c)
tf0}
where
tf0 :: a -> Transition a (col c)
tf0 a
a0 = case (forall a b. SF a b -> a -> Transition a b
sfTF SF (a, col c) (Event d)
sfe0) (a
a0, col c
cs0) of
(SF' (a, col c) (Event d)
sfe, Event d
NoEvent) -> (col (SF' b c) -> SF' (a, col c) (Event d) -> SF' a (col c)
pSwitchAux col (SF' b c)
sfs SF' (a, col c) (Event d)
sfe, col c
cs0)
(SF' (a, col c) (Event d)
_, Event d
d0) -> forall a b. SF a b -> a -> Transition a b
sfTF (col (SF b c) -> d -> SF a (col c)
k col (SF b c)
sfs0 d
d0) a
a0
where
bsfs0 :: col (b, SF b c)
bsfs0 = forall sf. a -> col sf -> col (b, sf)
rf a
a0 col (SF b c)
sfs0
sfcs0 :: col (Transition b c)
sfcs0 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(b
b0, SF b c
sf0) -> (forall a b. SF a b -> a -> Transition a b
sfTF SF b c
sf0) b
b0) col (b, SF b c)
bsfs0
sfs :: col (SF' b c)
sfs = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> a
fst col (Transition b c)
sfcs0
cs0 :: col c
cs0 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd col (Transition b c)
sfcs0
pSwitchAux :: col (SF' b c) -> SF' (a, col c) (Event d) -> SF' a (col c)
pSwitchAux col (SF' b c)
sfs (SFArr DTime -> (a, col c) -> (SF' (a, col c) (Event d), Event d)
_ (FDC Event d
NoEvent)) = forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF' b c) -> SF' a (col c)
parAux forall sf. a -> col sf -> col (b, sf)
rf col (SF' b c)
sfs
pSwitchAux col (SF' b c)
sfs SF' (a, col c) (Event d)
sfe = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> Transition a (col c)
tf
where
tf :: DTime -> a -> Transition a (col c)
tf DTime
dt a
a = case (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' (a, col c) (Event d)
sfe) DTime
dt (a
a, col c
cs) of
(SF' (a, col c) (Event d)
sfe', Event d
NoEvent) -> (col (SF' b c) -> SF' (a, col c) (Event d) -> SF' a (col c)
pSwitchAux col (SF' b c)
sfs' SF' (a, col c) (Event d)
sfe', col c
cs)
(SF' (a, col c) (Event d)
_, Event d
d) -> forall a b. SF a b -> a -> Transition a b
sfTF (col (SF b c) -> d -> SF a (col c)
k (forall (col :: * -> *) a b.
Functor col =>
col (SF' a b) -> DTime -> col (SF a b)
freezeCol col (SF' b c)
sfs DTime
dt) d
d) a
a
where
bsfs :: col (b, SF' b c)
bsfs = forall sf. a -> col sf -> col (b, sf)
rf a
a col (SF' b c)
sfs
sfcs' :: col (Transition b c)
sfcs' = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(b
b, SF' b c
sf) -> (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' b c
sf) DTime
dt b
b) col (b, SF' b c)
bsfs
sfs' :: col (SF' b c)
sfs' = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> a
fst col (Transition b c)
sfcs'
cs :: col c
cs = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd col (Transition b c)
sfcs'
dpSwitch :: Functor col
=> (forall sf . (a -> col sf -> col (b, sf)))
-> col (SF b c)
-> SF (a, col c) (Event d)
-> (col (SF b c) -> d -> SF a (col c))
-> SF a (col c)
dpSwitch :: forall (col :: * -> *) a b c d.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, col c) (Event d)
-> (col (SF b c) -> d -> SF a (col c))
-> SF a (col c)
dpSwitch forall sf. a -> col sf -> col (b, sf)
rf col (SF b c)
sfs0 SF (a, col c) (Event d)
sfe0 col (SF b c) -> d -> SF a (col c)
k = SF {sfTF :: a -> Transition a (col c)
sfTF = a -> Transition a (col c)
tf0}
where
tf0 :: a -> Transition a (col c)
tf0 a
a0 = ( case (forall a b. SF a b -> a -> Transition a b
sfTF SF (a, col c) (Event d)
sfe0) (a
a0, col c
cs0) of
(SF' (a, col c) (Event d)
sfe, Event d
NoEvent) -> col (SF' b c) -> SF' (a, col c) (Event d) -> SF' a (col c)
dpSwitchAux (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> a
fst col (Transition b c)
sfcs0) SF' (a, col c) (Event d)
sfe
(SF' (a, col c) (Event d)
_, Event d
d0) -> forall a b. (a, b) -> a
fst (forall a b. SF a b -> a -> Transition a b
sfTF (col (SF b c) -> d -> SF a (col c)
k col (SF b c)
sfs0 d
d0) a
a0)
, col c
cs0
)
where
bsfs0 :: col (b, SF b c)
bsfs0 = forall sf. a -> col sf -> col (b, sf)
rf a
a0 col (SF b c)
sfs0
sfcs0 :: col (Transition b c)
sfcs0 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(b
b0, SF b c
sf0) -> (forall a b. SF a b -> a -> Transition a b
sfTF SF b c
sf0) b
b0) col (b, SF b c)
bsfs0
cs0 :: col c
cs0 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd col (Transition b c)
sfcs0
dpSwitchAux :: col (SF' b c) -> SF' (a, col c) (Event d) -> SF' a (col c)
dpSwitchAux col (SF' b c)
sfs (SFArr DTime -> (a, col c) -> (SF' (a, col c) (Event d), Event d)
_ (FDC Event d
NoEvent)) = forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF' b c) -> SF' a (col c)
parAux forall sf. a -> col sf -> col (b, sf)
rf col (SF' b c)
sfs
dpSwitchAux col (SF' b c)
sfs SF' (a, col c) (Event d)
sfe = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> a -> Transition a (col c)
tf
where
tf :: DTime -> a -> Transition a (col c)
tf DTime
dt a
a = ( case (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' (a, col c) (Event d)
sfe) DTime
dt (a
a, col c
cs) of
(SF' (a, col c) (Event d)
sfe', Event d
NoEvent) -> col (SF' b c) -> SF' (a, col c) (Event d) -> SF' a (col c)
dpSwitchAux (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> a
fst col (Transition b c)
sfcs') SF' (a, col c) (Event d)
sfe'
(SF' (a, col c) (Event d)
_, Event d
d) -> forall a b. (a, b) -> a
fst (forall a b. SF a b -> a -> Transition a b
sfTF (col (SF b c) -> d -> SF a (col c)
k (forall (col :: * -> *) a b.
Functor col =>
col (SF' a b) -> DTime -> col (SF a b)
freezeCol col (SF' b c)
sfs DTime
dt) d
d) a
a)
, col c
cs
)
where
bsfs :: col (b, SF' b c)
bsfs = forall sf. a -> col sf -> col (b, sf)
rf a
a col (SF' b c)
sfs
sfcs' :: col (Transition b c)
sfcs' = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(b
b, SF' b c
sf) -> (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' b c
sf) DTime
dt b
b) col (b, SF' b c)
bsfs
cs :: col c
cs = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd col (Transition b c)
sfcs'
rpSwitch :: Functor col
=> (forall sf . (a -> col sf -> col (b, sf)))
-> col (SF b c)
-> SF (a, Event (col (SF b c) -> col (SF b c))) (col c)
rpSwitch :: forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, Event (col (SF b c) -> col (SF b c))) (col c)
rpSwitch forall sf. a -> col sf -> col (b, sf)
rf col (SF b c)
sfs =
forall (col :: * -> *) a b c d.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, col c) (Event d)
-> (col (SF b c) -> d -> SF a (col c))
-> SF a (col c)
pSwitch (forall sf. a -> col sf -> col (b, sf)
rf forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst) col (SF b c)
sfs (forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (forall a b. (a, b) -> b
snd forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst)) forall a b. (a -> b) -> a -> b
$ \col (SF b c)
sfs' col (SF b c) -> col (SF b c)
f ->
forall a b c. (a, Event b) -> (a, Event c)
noEventSnd forall a b. (a -> a) -> SF a b -> SF a b
>=- forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, Event (col (SF b c) -> col (SF b c))) (col c)
rpSwitch forall sf. a -> col sf -> col (b, sf)
rf (col (SF b c) -> col (SF b c)
f col (SF b c)
sfs')
drpSwitch :: Functor col
=> (forall sf . (a -> col sf -> col (b, sf)))
-> col (SF b c)
-> SF (a, Event (col (SF b c) -> col (SF b c))) (col c)
drpSwitch :: forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, Event (col (SF b c) -> col (SF b c))) (col c)
drpSwitch forall sf. a -> col sf -> col (b, sf)
rf col (SF b c)
sfs =
forall (col :: * -> *) a b c d.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, col c) (Event d)
-> (col (SF b c) -> d -> SF a (col c))
-> SF a (col c)
dpSwitch (forall sf. a -> col sf -> col (b, sf)
rf forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst) col (SF b c)
sfs (forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (forall a b. (a, b) -> b
snd forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst)) forall a b. (a -> b) -> a -> b
$ \col (SF b c)
sfs' col (SF b c) -> col (SF b c)
f ->
forall a b c. (a, Event b) -> (a, Event c)
noEventSnd forall a b. (a -> a) -> SF a b -> SF a b
>=- forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, Event (col (SF b c) -> col (SF b c))) (col c)
drpSwitch forall sf. a -> col sf -> col (b, sf)
rf (col (SF b c) -> col (SF b c)
f col (SF b c)
sfs')
parZ :: [SF a b] -> SF [a] [b]
parZ :: forall a b. [SF a b] -> SF [a] [b]
parZ = forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c) -> SF a (col c)
par (forall a b. String -> [a] -> [b] -> [(a, b)]
safeZip String
"parZ")
pSwitchZ :: [SF a b]
-> SF ([a], [b]) (Event c)
-> ([SF a b] -> c -> SF [a] [b])
-> SF [a] [b]
pSwitchZ :: forall a b c.
[SF a b]
-> SF ([a], [b]) (Event c)
-> ([SF a b] -> c -> SF [a] [b])
-> SF [a] [b]
pSwitchZ = forall (col :: * -> *) a b c d.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, col c) (Event d)
-> (col (SF b c) -> d -> SF a (col c))
-> SF a (col c)
pSwitch (forall a b. String -> [a] -> [b] -> [(a, b)]
safeZip String
"pSwitchZ")
dpSwitchZ :: [SF a b]
-> SF ([a], [b]) (Event c)
-> ([SF a b] -> c -> SF [a] [b])
-> SF [a] [b]
dpSwitchZ :: forall a b c.
[SF a b]
-> SF ([a], [b]) (Event c)
-> ([SF a b] -> c -> SF [a] [b])
-> SF [a] [b]
dpSwitchZ = forall (col :: * -> *) a b c d.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, col c) (Event d)
-> (col (SF b c) -> d -> SF a (col c))
-> SF a (col c)
dpSwitch (forall a b. String -> [a] -> [b] -> [(a, b)]
safeZip String
"dpSwitchZ")
rpSwitchZ :: [SF a b] -> SF ([a], Event ([SF a b] -> [SF a b])) [b]
rpSwitchZ :: forall a b. [SF a b] -> SF ([a], Event ([SF a b] -> [SF a b])) [b]
rpSwitchZ = forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, Event (col (SF b c) -> col (SF b c))) (col c)
rpSwitch (forall a b. String -> [a] -> [b] -> [(a, b)]
safeZip String
"rpSwitchZ")
drpSwitchZ :: [SF a b] -> SF ([a], Event ([SF a b] -> [SF a b])) [b]
drpSwitchZ :: forall a b. [SF a b] -> SF ([a], Event ([SF a b] -> [SF a b])) [b]
drpSwitchZ = forall (col :: * -> *) a b c.
Functor col =>
(forall sf. a -> col sf -> col (b, sf))
-> col (SF b c)
-> SF (a, Event (col (SF b c) -> col (SF b c))) (col c)
drpSwitch (forall a b. String -> [a] -> [b] -> [(a, b)]
safeZip String
"drpSwitchZ")
safeZip :: String -> [a] -> [b] -> [(a, b)]
safeZip :: forall a b. String -> [a] -> [b] -> [(a, b)]
safeZip String
fn [a]
l1 [b]
l2 = forall a b. [a] -> [b] -> [(a, b)]
safeZip' [a]
l1 [b]
l2
where
safeZip' :: [a] -> [b] -> [(a, b)]
safeZip' :: forall a b. [a] -> [b] -> [(a, b)]
safeZip' [a]
_ [] = []
safeZip' [a]
as (b
b:[b]
bs) = (forall a. [a] -> a
head' [a]
as, b
b) forall a. a -> [a] -> [a]
: forall a b. [a] -> [b] -> [(a, b)]
safeZip' (forall a. [a] -> [a]
tail' [a]
as) [b]
bs
head' :: [a] -> a
head' :: forall a. [a] -> a
head' [] = forall a. a
err
head' (a
a:[a]
_) = a
a
tail' :: [a] -> [a]
tail' :: forall a. [a] -> [a]
tail' [] = forall a. a
err
tail' (a
_:[a]
as) = [a]
as
err :: a
err :: forall a. a
err = forall a. String -> String -> String -> a
usrErr String
"FRP.Yampa.Switches" String
fn String
"Input list too short."
freeze :: SF' a b -> DTime -> SF a b
freeze :: forall a b. SF' a b -> DTime -> SF a b
freeze SF' a b
sf DTime
dt = SF {sfTF :: a -> Transition a b
sfTF = (forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' a b
sf) DTime
dt}
freezeCol :: Functor col => col (SF' a b) -> DTime -> col (SF a b)
freezeCol :: forall (col :: * -> *) a b.
Functor col =>
col (SF' a b) -> DTime -> col (SF a b)
freezeCol col (SF' a b)
sfs DTime
dt = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b. SF' a b -> DTime -> SF a b
`freeze` DTime
dt) col (SF' a b)
sfs
parC :: SF a b -> SF [a] [b]
parC :: forall a b. SF a b -> SF [a] [b]
parC SF a b
sf = forall a b. (a -> Transition a b) -> SF a b
SF forall a b. (a -> b) -> a -> b
$ \[a]
as -> let os :: [Transition a b]
os = forall a b. (a -> b) -> [a] -> [b]
map (forall a b. SF a b -> a -> Transition a b
sfTF SF a b
sf) [a]
as
bs :: [b]
bs = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [Transition a b]
os
sfs :: [SF' a b]
sfs = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [Transition a b]
os
in (forall a b. [SF' a b] -> SF' [a] [b]
parCAux [SF' a b]
sfs, [b]
bs)
parCAux :: [SF' a b] -> SF' [a] [b]
parCAux :: forall a b. [SF' a b] -> SF' [a] [b]
parCAux [SF' a b]
sfs = forall a b. (DTime -> a -> Transition a b) -> SF' a b
SF' DTime -> [a] -> (SF' [a] [b], [b])
tf
where
tf :: DTime -> [a] -> (SF' [a] [b], [b])
tf DTime
dt [a]
as = (forall a. [a] -> [a]
listSeq [SF' a b]
sfcs seq :: forall a b. a -> b -> b
`seq` forall a b. [SF' a b] -> SF' [a] [b]
parCAux [SF' a b]
sfcs, forall a. [a] -> [a]
listSeq [b]
bs)
where
os :: [Transition a b]
os = forall a b. (a -> b) -> [a] -> [b]
map (\(a
a, SF' a b
sf) -> forall a b. SF' a b -> DTime -> a -> Transition a b
sfTF' SF' a b
sf DTime
dt a
a) forall a b. (a -> b) -> a -> b
$ forall a b. String -> [a] -> [b] -> [(a, b)]
safeZip String
"parC" [a]
as [SF' a b]
sfs
bs :: [b]
bs = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [Transition a b]
os
sfcs :: [SF' a b]
sfcs = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [Transition a b]
os
listSeq :: [a] -> [a]
listSeq :: forall a. [a] -> [a]
listSeq [a]
x = [a]
x seq :: forall a b. a -> b -> b
`seq` (forall a. [a] -> [a]
listSeq' [a]
x)
listSeq' :: [a] -> [a]
listSeq' :: forall a. [a] -> [a]
listSeq' [] = []
listSeq' rs :: [a]
rs@(a
a:[a]
as) = a
a seq :: forall a b. a -> b -> b
`seq` forall a. [a] -> [a]
listSeq' [a]
as seq :: forall a b. a -> b -> b
`seq` [a]
rs