{-# LANGUAGE PostfixOperators #-}
{-# OPTIONS_HADDOCK hide #-}

module ForSyDe.Atom.MoC.DE.Interface where

import           ForSyDe.Atom.MoC.DE.Lib (sync2, sync3, sync4)
import           ForSyDe.Atom.MoC.Stream (Stream(..))
import qualified ForSyDe.Atom.Skel.Vector as V (
  Vector, vector, zipx, unzipx, fanout, length, reverse)
import           ForSyDe.Atom.Utility.Tuple

import qualified ForSyDe.Atom.MoC.DE.Core as DE
import qualified ForSyDe.Atom.MoC.SY.Core as SY
import qualified ForSyDe.Atom.MoC.CT.Core as CT

import Prelude hiding ((<>))

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

-- $setup
-- >>> import ForSyDe.Atom.MoC.DE.Lib

------- MoC INTERFACES -------

-- | Synchronizes a (set of) 'ForSyDe.Atom.MoC.DE.DE' signal(s) an
-- strips off their explicit tags, outputting the equivalent
-- 'ForSyDe.Atom.MoC.SY.SY' signal(s), tupled with an SY signal
-- carrying the timestamps for the synchronization points.
--
-- Constructors: @toSY[1-4]@
--
-- >>> let s1 = DE.infinite 1
-- >>> let s2 = DE.readSignal "{1@0, 2@2, 3@6, 4@8, 5@9}" :: DE.Signal Int
-- >>> toSY2 s1 s2
-- ({0s,2s,6s,8s,9s},{1,1,1,1,1},{1,2,3,4,5})
--
-- <<fig/moc-de-tosy.png>>
toSY2 :: (Num t, Ord t, Eq t)
      => DE.SignalBase t a             -- ^ first input DE signal
      -> DE.SignalBase t b             -- ^ second input DE signal
      -> (SY.Signal t, SY.Signal a, SY.Signal b)
      -- ^ signal carrying timestamps tupled with the two output
      -- 'ForSyDe.Atom.MoC.SY.SY' signals
toSY1 :: (Num t, Ord t, Eq t)
      => DE.SignalBase t a
      -> (SY.Signal t, SY.Signal a)
toSY3 :: (Num t, Ord t, Eq t)
      => DE.SignalBase t a -> DE.SignalBase t b -> DE.SignalBase t c
      -> (SY.Signal t, SY.Signal a, SY.Signal b, SY.Signal c)
toSY4 :: (Num t, Ord t, Eq t)
      => DE.SignalBase t a -> DE.SignalBase t b -> DE.SignalBase t c
      -> DE.SignalBase t d
      -> (SY.Signal t, SY.Signal a, SY.Signal b, SY.Signal c, SY.Signal d)

eventToSY :: DE t a -> (SY t, SY a)
eventToSY (DE.DE t :: t
t a :: a
a) = (t -> SY t
forall a. a -> SY a
SY.SY t
t, a -> SY a
forall a. a -> SY a
SY.SY a
a)
toSY1 :: SignalBase t a -> (Signal t, Signal a)
toSY1 s1 :: SignalBase t a
s1              = (DE t a -> (SY t, SY a)
forall t a. DE t a -> (SY t, SY a)
eventToSY (DE t a -> (SY t, SY a)) -> SignalBase t a -> Stream (SY t, SY a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SignalBase t a
s1 Stream (SY t, SY a) -> (Signal t, Signal a)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
|<)
toSY2 :: SignalBase t a -> SignalBase t b -> (Signal t, Signal a, Signal b)
toSY2 s1 :: SignalBase t a
s1 s2 :: SignalBase t b
s2
  = let (sy1 :: (Signal t, Signal a)
sy1,sy2 :: (Signal t, Signal b)
sy2) = (SignalBase t a -> (Signal t, Signal a)
forall t a.
(Num t, Ord t, Eq t) =>
SignalBase t a -> (Signal t, Signal a)
toSY1,SignalBase t b -> (Signal t, Signal b)
forall t a.
(Num t, Ord t, Eq t) =>
SignalBase t a -> (Signal t, Signal a)
toSY1) (SignalBase t a -> (Signal t, Signal a),
 SignalBase t b -> (Signal t, Signal b))
-> (SignalBase t a, SignalBase t b)
-> ((Signal t, Signal a), (Signal t, Signal b))
forall a1 b1 a2 b2. (a1 -> b1, a2 -> b2) -> (a1, a2) -> (b1, b2)
$$ SignalBase t a
-> SignalBase t b -> (SignalBase t a, SignalBase t b)
forall t a1 a2.
(Num t, Ord t, Eq t) =>
SignalBase t a1
-> SignalBase t a2 -> (SignalBase t a1, SignalBase t a2)
sync2 SignalBase t a
s1 SignalBase t b
s2
    in  ((Signal t, Signal a) -> Signal t
forall a b. (a, b) -> a
fst,(Signal t, Signal a) -> Signal a
forall a b. (a, b) -> b
snd,(Signal t, Signal b) -> Signal b
forall a b. (a, b) -> b
snd) ((Signal t, Signal a) -> Signal t,
 (Signal t, Signal a) -> Signal a, (Signal t, Signal b) -> Signal b)
-> ((Signal t, Signal a), (Signal t, Signal a),
    (Signal t, Signal b))
-> (Signal t, Signal a, Signal b)
forall t1 a t2 b t3 c.
(t1 -> a, t2 -> b, t3 -> c) -> (t1, t2, t3) -> (a, b, c)
$$$ ((Signal t, Signal a)
sy1,(Signal t, Signal a)
sy1,(Signal t, Signal b)
sy2) 
toSY3 :: SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> (Signal t, Signal a, Signal b, Signal c)
toSY3 s1 :: SignalBase t a
s1 s2 :: SignalBase t b
s2 s3 :: SignalBase t c
s3
  = let (sy1 :: (Signal t, Signal a)
sy1,sy2 :: (Signal t, Signal b)
sy2,sy3 :: (Signal t, Signal c)
sy3) = (SignalBase t a -> (Signal t, Signal a)
forall t a.
(Num t, Ord t, Eq t) =>
SignalBase t a -> (Signal t, Signal a)
toSY1,SignalBase t b -> (Signal t, Signal b)
forall t a.
(Num t, Ord t, Eq t) =>
SignalBase t a -> (Signal t, Signal a)
toSY1,SignalBase t c -> (Signal t, Signal c)
forall t a.
(Num t, Ord t, Eq t) =>
SignalBase t a -> (Signal t, Signal a)
toSY1) (SignalBase t a -> (Signal t, Signal a),
 SignalBase t b -> (Signal t, Signal b),
 SignalBase t c -> (Signal t, Signal c))
-> (SignalBase t a, SignalBase t b, SignalBase t c)
-> ((Signal t, Signal a), (Signal t, Signal b),
    (Signal t, Signal c))
forall t1 a t2 b t3 c.
(t1 -> a, t2 -> b, t3 -> c) -> (t1, t2, t3) -> (a, b, c)
$$$ SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> (SignalBase t a, SignalBase t b, SignalBase t c)
forall t a1 a2 a3.
(Num t, Ord t, Eq t) =>
SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3)
sync3 SignalBase t a
s1 SignalBase t b
s2 SignalBase t c
s3
    in  ((Signal t, Signal a) -> Signal t
forall a b. (a, b) -> a
fst,(Signal t, Signal a) -> Signal a
forall a b. (a, b) -> b
snd,(Signal t, Signal b) -> Signal b
forall a b. (a, b) -> b
snd,(Signal t, Signal c) -> Signal c
forall a b. (a, b) -> b
snd) ((Signal t, Signal a) -> Signal t,
 (Signal t, Signal a) -> Signal a, (Signal t, Signal b) -> Signal b,
 (Signal t, Signal c) -> Signal c)
-> ((Signal t, Signal a), (Signal t, Signal a),
    (Signal t, Signal b), (Signal t, Signal c))
-> (Signal t, Signal a, Signal b, Signal c)
forall t1 a t2 b t3 c t4 d.
(t1 -> a, t2 -> b, t3 -> c, t4 -> d)
-> (t1, t2, t3, t4) -> (a, b, c, d)
$$$$ ((Signal t, Signal a)
sy1,(Signal t, Signal a)
sy1,(Signal t, Signal b)
sy2,(Signal t, Signal c)
sy3)  
toSY4 :: SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> SignalBase t d
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
toSY4 s1 :: SignalBase t a
s1 s2 :: SignalBase t b
s2 s3 :: SignalBase t c
s3 s4 :: SignalBase t d
s4  
  = let (sy1 :: (Signal t, Signal a)
sy1,sy2 :: (Signal t, Signal b)
sy2,sy3 :: (Signal t, Signal c)
sy3,sy4 :: (Signal t, Signal d)
sy4) = (SignalBase t a -> (Signal t, Signal a)
forall t a.
(Num t, Ord t, Eq t) =>
SignalBase t a -> (Signal t, Signal a)
toSY1,SignalBase t b -> (Signal t, Signal b)
forall t a.
(Num t, Ord t, Eq t) =>
SignalBase t a -> (Signal t, Signal a)
toSY1,SignalBase t c -> (Signal t, Signal c)
forall t a.
(Num t, Ord t, Eq t) =>
SignalBase t a -> (Signal t, Signal a)
toSY1,SignalBase t d -> (Signal t, Signal d)
forall t a.
(Num t, Ord t, Eq t) =>
SignalBase t a -> (Signal t, Signal a)
toSY1) (SignalBase t a -> (Signal t, Signal a),
 SignalBase t b -> (Signal t, Signal b),
 SignalBase t c -> (Signal t, Signal c),
 SignalBase t d -> (Signal t, Signal d))
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
-> ((Signal t, Signal a), (Signal t, Signal b),
    (Signal t, Signal c), (Signal t, Signal d))
forall t1 a t2 b t3 c t4 d.
(t1 -> a, t2 -> b, t3 -> c, t4 -> d)
-> (t1, t2, t3, t4) -> (a, b, c, d)
$$$$ SignalBase t a
-> SignalBase t b
-> SignalBase t c
-> SignalBase t d
-> (SignalBase t a, SignalBase t b, SignalBase t c, SignalBase t d)
forall t a1 a2 a3 a4.
(Num t, Ord t, Eq t) =>
SignalBase t a1
-> SignalBase t a2
-> SignalBase t a3
-> SignalBase t a4
-> (SignalBase t a1, SignalBase t a2, SignalBase t a3,
    SignalBase t a4)
sync4 SignalBase t a
s1 SignalBase t b
s2 SignalBase t c
s3 SignalBase t d
s4
    in  ((Signal t, Signal a) -> Signal t
forall a b. (a, b) -> a
fst,(Signal t, Signal a) -> Signal a
forall a b. (a, b) -> b
snd,(Signal t, Signal b) -> Signal b
forall a b. (a, b) -> b
snd,(Signal t, Signal c) -> Signal c
forall a b. (a, b) -> b
snd,(Signal t, Signal d) -> Signal d
forall a b. (a, b) -> b
snd) ((Signal t, Signal a) -> Signal t,
 (Signal t, Signal a) -> Signal a, (Signal t, Signal b) -> Signal b,
 (Signal t, Signal c) -> Signal c, (Signal t, Signal d) -> Signal d)
-> ((Signal t, Signal a), (Signal t, Signal a),
    (Signal t, Signal b), (Signal t, Signal c), (Signal t, Signal d))
-> (Signal t, Signal a, Signal b, Signal c, Signal d)
forall t1 a t2 b t3 c t4 d t5 e.
(t1 -> a, t2 -> b, t3 -> c, t4 -> d, t5 -> e)
-> (t1, t2, t3, t4, t5) -> (a, b, c, d, e)
$$$$$ ((Signal t, Signal a)
sy1,(Signal t, Signal a)
sy1,(Signal t, Signal b)
sy2,(Signal t, Signal c)
sy3,(Signal t, Signal d)
sy4) 


-- | Semantic preserving transformation between a (set of) DE
-- signal(s) and the equivalent CT signals. The
-- 'ForSyDe.Atom.MoC.DE.DE' events must carry a function of 'Time'
-- which will be lifted by providing it with 'ForSyDe.Atom.MoC.CT.CT'
-- implicit time semantics.
--
-- Constructors: @toCT[1-4]@.
--
-- <<fig/moc-de-toct.png>>
toCT2 :: (Num ts, Real ts, Ord ts, Eq ts, Num tm, Fractional tm, Ord tm) 
      => DE.SignalBase ts (tm -> a)  -- ^ first input DE signal
      -> DE.SignalBase ts (tm -> b)  -- ^ second input DE signal
      -> (CT.SignalBase ts tm a, CT.SignalBase ts tm b)
      -- ^ two output 'ForSyDe.Atom.MoC.CT.CT' signals
eventToCT :: DE t (time -> a) -> CT t time a
eventToCT (DE.DE t :: t
t a :: time -> a
a) = t -> time -> (time -> a) -> CT t time a
forall time timestamp a.
(Num time, Num timestamp, Ord timestamp, Eq timestamp) =>
timestamp -> time -> (time -> a) -> CT timestamp time a
CT.CT t
t 0 time -> a
a
toCT1 :: f (DE t (time -> a)) -> f (CT t time a)
toCT1 s1 :: f (DE t (time -> a))
s1          = DE t (time -> a) -> CT t time a
forall time t a. Num time => DE t (time -> a) -> CT t time a
eventToCT (DE t (time -> a) -> CT t time a)
-> f (DE t (time -> a)) -> f (CT t time a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (DE t (time -> a))
s1
toCT2 :: SignalBase ts (tm -> a)
-> SignalBase ts (tm -> b)
-> (SignalBase ts tm a, SignalBase ts tm b)
toCT2 s1 :: SignalBase ts (tm -> a)
s1 s2 :: SignalBase ts (tm -> b)
s2       = (SignalBase ts (tm -> a) -> SignalBase ts tm a
forall (f :: * -> *) time t a.
(Functor f, Num time) =>
f (DE t (time -> a)) -> f (CT t time a)
toCT1, SignalBase ts (tm -> b) -> SignalBase ts tm b
forall (f :: * -> *) time t a.
(Functor f, Num time) =>
f (DE t (time -> a)) -> f (CT t time a)
toCT1) (SignalBase ts (tm -> a) -> SignalBase ts tm a,
 SignalBase ts (tm -> b) -> SignalBase ts tm b)
-> (SignalBase ts (tm -> a), SignalBase ts (tm -> b))
-> (SignalBase ts tm a, SignalBase ts tm b)
forall a1 b1 a2 b2. (a1 -> b1, a2 -> b2) -> (a1, a2) -> (b1, b2)
$$ (SignalBase ts (tm -> a)
s1,SignalBase ts (tm -> b)
s2)
toCT3 :: f (DE t (time -> a))
-> f (DE t (time -> a))
-> f (DE t (time -> a))
-> (f (CT t time a), f (CT t time a), f (CT t time a))
toCT3 s1 :: f (DE t (time -> a))
s1 s2 :: f (DE t (time -> a))
s2 s3 :: f (DE t (time -> a))
s3    = (f (DE t (time -> a)) -> f (CT t time a)
forall (f :: * -> *) time t a.
(Functor f, Num time) =>
f (DE t (time -> a)) -> f (CT t time a)
toCT1, f (DE t (time -> a)) -> f (CT t time a)
forall (f :: * -> *) time t a.
(Functor f, Num time) =>
f (DE t (time -> a)) -> f (CT t time a)
toCT1, f (DE t (time -> a)) -> f (CT t time a)
forall (f :: * -> *) time t a.
(Functor f, Num time) =>
f (DE t (time -> a)) -> f (CT t time a)
toCT1) (f (DE t (time -> a)) -> f (CT t time a),
 f (DE t (time -> a)) -> f (CT t time a),
 f (DE t (time -> a)) -> f (CT t time a))
-> (f (DE t (time -> a)), f (DE t (time -> a)),
    f (DE t (time -> a)))
-> (f (CT t time a), f (CT t time a), f (CT t time a))
forall t1 a t2 b t3 c.
(t1 -> a, t2 -> b, t3 -> c) -> (t1, t2, t3) -> (a, b, c)
$$$ (f (DE t (time -> a))
s1,f (DE t (time -> a))
s2,f (DE t (time -> a))
s3)
toCT4 :: f (DE t (time -> a))
-> f (DE t (time -> a))
-> f (DE t (time -> a))
-> f (DE t (time -> a))
-> (f (CT t time a), f (CT t time a), f (CT t time a),
    f (CT t time a))
toCT4 s1 :: f (DE t (time -> a))
s1 s2 :: f (DE t (time -> a))
s2 s3 :: f (DE t (time -> a))
s3 s4 :: f (DE t (time -> a))
s4 = (f (DE t (time -> a)) -> f (CT t time a)
forall (f :: * -> *) time t a.
(Functor f, Num time) =>
f (DE t (time -> a)) -> f (CT t time a)
toCT1, f (DE t (time -> a)) -> f (CT t time a)
forall (f :: * -> *) time t a.
(Functor f, Num time) =>
f (DE t (time -> a)) -> f (CT t time a)
toCT1, f (DE t (time -> a)) -> f (CT t time a)
forall (f :: * -> *) time t a.
(Functor f, Num time) =>
f (DE t (time -> a)) -> f (CT t time a)
toCT1, f (DE t (time -> a)) -> f (CT t time a)
forall (f :: * -> *) time t a.
(Functor f, Num time) =>
f (DE t (time -> a)) -> f (CT t time a)
toCT1) (f (DE t (time -> a)) -> f (CT t time a),
 f (DE t (time -> a)) -> f (CT t time a),
 f (DE t (time -> a)) -> f (CT t time a),
 f (DE t (time -> a)) -> f (CT t time a))
-> (f (DE t (time -> a)), f (DE t (time -> a)),
    f (DE t (time -> a)), f (DE t (time -> a)))
-> (f (CT t time a), f (CT t time a), f (CT t time a),
    f (CT t time a))
forall t1 a t2 b t3 c t4 d.
(t1 -> a, t2 -> b, t3 -> c, t4 -> d)
-> (t1, t2, t3, t4) -> (a, b, c, d)
$$$$ (f (DE t (time -> a))
s1,f (DE t (time -> a))
s2,f (DE t (time -> a))
s3,f (DE t (time -> a))
s4)

-- Towards skeleton layer

-- | Synchronizes all the signals contained by a vector and zips them
-- into one signal of vectors. It instantiates the
-- 'ForSyDe.Atom.Skel.Vector.zipx' skeleton.
--
-- >>> let s1 = DE.readSignal "{1@0, 2@2, 3@6, 4@8, 5@9}" :: DE.Signal Int
-- >>> let s2 = DE.readSignal "{1@0, 2@2, 3@4, 4@8, 5@9}" :: DE.Signal Int
-- >>> let v1 = V.vector [s1,s1,s2,s2]
-- >>> v1
-- <{1@0s,2@2s,3@6s,4@8s,5@9s},{1@0s,2@2s,3@6s,4@8s,5@9s},{1@0s,2@2s,3@4s,4@8s,5@9s},{1@0s,2@2s,3@4s,4@8s,5@9s}>
-- >>> zipx v1
-- {<1,1,1,1>@0s,<2,2,2,2>@2s,<2,2,3,3>@4s,<3,3,3,3>@6s,<4,4,4,4>@8s,<5,5,5,5>@9s}
--
-- <<fig/moc-de-zipx.png>>
zipx ::(Num t, Ord t, Eq t)
     => V.Vector (DE.SignalBase t a) -> DE.SignalBase t (V.Vector a)
zipx :: Vector (SignalBase t a) -> SignalBase t (Vector a)
zipx = Vector
  ((Vector a -> Vector a -> Vector a)
   -> Fun
        (DE t) (Vector a) (Fun (DE t) (Vector a) (Ret (DE t) (Vector a))))
-> Vector (SignalBase t a) -> SignalBase t (Vector a)
forall (e :: * -> *) a.
MoC e =>
Vector
  ((Vector a -> Vector a -> Vector a)
   -> Fun e (Vector a) (Fun e (Vector a) (Ret e (Vector a))))
-> Vector (Stream (e a)) -> Stream (e (Vector a))
V.zipx (((Vector a -> Vector a -> Vector a)
 -> Vector a -> Vector a -> Vector a)
-> Vector
     ((Vector a -> Vector a -> Vector a)
      -> Vector a -> Vector a -> Vector a)
forall t. t -> Vector t
V.fanout (\cat :: Vector a -> Vector a -> Vector a
cat a :: Vector a
a b :: Vector a
b -> Vector a
a Vector a -> Vector a -> Vector a
`cat` Vector a
b))

-- | Unzips the vectors carried by a signal into a vector of
-- signals. It instantiates the 'ForSyDe.Atom.Skel.Vector.unzipx'
-- skeleton. To avoid infinite recurrence, the user needs to provide
-- the length of the output vector.
--
-- >>> let v1 = V.vector [1,2,3,4]
-- >>> let s1 = DE.signal [(0,v1),(2,v1),(6,v1),(8,v1),(9,v1)] :: DE.Signal (V.Vector Int)
-- >>> s1
-- {<1,2,3,4>@0s,<1,2,3,4>@2s,<1,2,3,4>@6s,<1,2,3,4>@8s,<1,2,3,4>@9s}
-- >>> unzipx 4 s1
-- <{1@0s,1@2s,1@6s,1@8s,1@9s},{2@0s,2@2s,2@6s,2@8s,2@9s},{3@0s,3@2s,3@6s,3@8s,3@9s},{4@0s,4@2s,4@6s,4@8s,4@9s}>
--
-- <<fig/moc-de-unzipx.png>>
unzipx :: (Num t, Ord t, Eq t)
       => Integer -> DE.SignalBase t (V.Vector a) -> V.Vector (DE.SignalBase t a)
unzipx :: Integer -> SignalBase t (Vector a) -> Vector (SignalBase t a)
unzipx n :: Integer
n = Vector (SignalBase t a) -> Vector (SignalBase t a)
forall a. Vector a -> Vector a
V.reverse (Vector (SignalBase t a) -> Vector (SignalBase t a))
-> (SignalBase t (Vector a) -> Vector (SignalBase t a))
-> SignalBase t (Vector a)
-> Vector (SignalBase t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Vector a -> Vector (Ret (DE t) a))
-> Integer -> SignalBase t (Vector a) -> Vector (SignalBase t a)
forall (e :: * -> *) a.
MoC e =>
(Vector a -> Vector (Ret e a))
-> Integer -> Stream (e (Vector a)) -> Vector (Stream (e a))
V.unzipx Vector a -> Vector (Ret (DE t) a)
forall a. a -> a
id Integer
n

-- | Same as 'unzipx', but \"sniffs\" the first event to determine the length of the output vector. Might have unsafe behavior!
--
-- >>> let v1 = V.vector [1,2,3,4]
-- >>> let s1 = DE.signal [(0,v1),(2,v1),(6,v1),(8,v1),(9,v1)] :: DE.Signal (V.Vector Int)
-- >>> s1
-- {<1,2,3,4>@0s,<1,2,3,4>@2s,<1,2,3,4>@6s,<1,2,3,4>@8s,<1,2,3,4>@9s}
-- >>> unzipx' s1
-- <{1@0s,1@2s,1@6s,1@8s,1@9s},{2@0s,2@2s,2@6s,2@8s,2@9s},{3@0s,3@2s,3@6s,3@8s,3@9s},{4@0s,4@2s,4@6s,4@8s,4@9s}>
unzipx' :: (Num t, Ord t, Eq t)
        => DE.SignalBase t (V.Vector a) -> V.Vector (DE.SignalBase t a)
unzipx' :: SignalBase t (Vector a) -> Vector (SignalBase t a)
unzipx' s :: SignalBase t (Vector a)
s@(a :: DE t (Vector a)
a:-_) = Integer -> SignalBase t (Vector a) -> Vector (SignalBase t a)
forall t a.
(Num t, Ord t, Eq t) =>
Integer -> SignalBase t (Vector a) -> Vector (SignalBase t a)
unzipx (Vector a -> Integer
forall p a. Num p => Vector a -> p
V.length (Vector a -> Integer) -> Vector a -> Integer
forall a b. (a -> b) -> a -> b
$ DE t (Vector a) -> Vector a
forall t a. DE t a -> a
DE.val DE t (Vector a)
a) SignalBase t (Vector a)
s