{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
module FRP.Rhine.ClSF.Util where
import Control.Arrow
import Control.Category (Category)
import qualified Control.Category (id)
import Data.Maybe (fromJust)
import Data.Monoid (Last (Last), getLast)
import Data.Sequence
import Control.Monad.Trans.Reader (ask, asks)
import Control.Monad.Trans.MSF.Reader (readerS)
import Data.MonadicStreamFunction.Instances.VectorSpace ()
import Data.VectorSpace
import FRP.Rhine.ClSF.Core
import FRP.Rhine.ClSF.Except
import FRP.Rhine.Clock
timeInfo :: Monad m => ClSF m cl a (TimeInfo cl)
timeInfo :: forall (m :: Type -> Type) cl a.
Monad m =>
ClSF m cl a (TimeInfo cl)
timeInfo = forall (m :: Type -> Type) b a. Monad m => m b -> MSF m a b
constM forall (m :: Type -> Type) r. Monad m => ReaderT r m r
ask
timeInfoOf :: Monad m => (TimeInfo cl -> b) -> ClSF m cl a b
timeInfoOf :: forall (m :: Type -> Type) cl b a.
Monad m =>
(TimeInfo cl -> b) -> ClSF m cl a b
timeInfoOf TimeInfo cl -> b
f = forall (m :: Type -> Type) b a. Monad m => m b -> MSF m a b
constM forall a b. (a -> b) -> a -> b
$ forall (m :: Type -> Type) r a.
Monad m =>
(r -> a) -> ReaderT r m a
asks TimeInfo cl -> b
f
sinceLastS :: Monad m => ClSF m cl a (Diff (Time cl))
sinceLastS :: forall (m :: Type -> Type) cl a.
Monad m =>
ClSF m cl a (Diff (Time cl))
sinceLastS = forall (m :: Type -> Type) cl b a.
Monad m =>
(TimeInfo cl -> b) -> ClSF m cl a b
timeInfoOf forall cl. TimeInfo cl -> Diff (Time cl)
sinceLast
sinceInitS :: Monad m => ClSF m cl a (Diff (Time cl))
sinceInitS :: forall (m :: Type -> Type) cl a.
Monad m =>
ClSF m cl a (Diff (Time cl))
sinceInitS = forall (m :: Type -> Type) cl b a.
Monad m =>
(TimeInfo cl -> b) -> ClSF m cl a b
timeInfoOf forall cl. TimeInfo cl -> Diff (Time cl)
sinceInit
absoluteS :: Monad m => ClSF m cl a (Time cl)
absoluteS :: forall (m :: Type -> Type) cl a. Monad m => ClSF m cl a (Time cl)
absoluteS = forall (m :: Type -> Type) cl b a.
Monad m =>
(TimeInfo cl -> b) -> ClSF m cl a b
timeInfoOf forall cl. TimeInfo cl -> Time cl
absolute
tagS :: Monad m => ClSF m cl a (Tag cl)
tagS :: forall (m :: Type -> Type) cl a. Monad m => ClSF m cl a (Tag cl)
tagS = forall (m :: Type -> Type) cl b a.
Monad m =>
(TimeInfo cl -> b) -> ClSF m cl a b
timeInfoOf forall cl. TimeInfo cl -> Tag cl
tag
sinceStart :: (Monad m, TimeDomain time) => BehaviourF m time a (Diff time)
sinceStart :: forall (m :: Type -> Type) time a.
(Monad m, TimeDomain time) =>
BehaviourF m time a (Diff time)
sinceStart =
forall (m :: Type -> Type) cl a. Monad m => ClSF m cl a (Time cl)
absoluteS forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> proc time
time -> do
time
startTime <- forall (m :: Type -> Type) cl a. Monad m => ClSF m cl a a
keepFirst -< time
time
forall (a :: Type -> Type -> Type) b. Arrow a => a b b
returnA -< time
time forall time. TimeDomain time => time -> time -> Diff time
`diffTime` time
startTime
infixr 6 >->
(>->) ::
Category cat =>
cat a b ->
cat b c ->
cat a c
>-> :: forall (cat :: Type -> Type -> Type) a b c.
Category cat =>
cat a b -> cat b c -> cat a c
(>->) = forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
(>>>)
infixl 6 <-<
(<-<) ::
Category cat =>
cat b c ->
cat a b ->
cat a c
<-< :: forall (cat :: Type -> Type -> Type) b c a.
Category cat =>
cat b c -> cat a b -> cat a c
(<-<) = forall {k} (cat :: k -> k -> Type) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
(<<<)
arr_ :: Arrow a => b -> a c b
arr_ :: forall (a :: Type -> Type -> Type) b c. Arrow a => b -> a c b
arr_ = forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> b -> a
const
clId :: Monad m => ClSF m cl a a
clId :: forall (m :: Type -> Type) cl a. Monad m => ClSF m cl a a
clId = forall {k} (cat :: k -> k -> Type) (a :: k).
Category cat =>
cat a a
Control.Category.id
integralFrom ::
( Monad m
, VectorSpace v s
, s ~ Diff td
) =>
v ->
BehaviorF m td v v
integralFrom :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> BehaviorF m td v v
integralFrom v
v0 = proc v
v -> do
s
_sinceLast <- forall (m :: Type -> Type) cl b a.
Monad m =>
(TimeInfo cl -> b) -> ClSF m cl a b
timeInfoOf forall cl. TimeInfo cl -> Diff (Time cl)
sinceLast -< ()
forall v s (m :: Type -> Type).
(VectorSpace v s, Monad m) =>
v -> MSF m v v
sumFrom v
v0 -< s
_sinceLast forall v a. VectorSpace v a => a -> v -> v
*^ v
v
integral ::
( Monad m
, VectorSpace v s
, s ~ Diff td
) =>
BehaviorF m td v v
integral :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
BehaviorF m td v v
integral = forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> BehaviorF m td v v
integralFrom forall v a. VectorSpace v a => v
zeroVector
derivativeFrom ::
( Monad m
, VectorSpace v s
, s ~ Diff td
) =>
v ->
BehaviorF m td v v
derivativeFrom :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> BehaviorF m td v v
derivativeFrom v
v0 = proc v
v -> do
v
vLast <- forall (m :: Type -> Type) a. Monad m => a -> MSF m a a
iPre v
v0 -< v
v
TimeInfo {Diff (Time cl)
Time cl
Tag cl
tag :: Tag cl
absolute :: Time cl
sinceInit :: Diff (Time cl)
sinceLast :: Diff (Time cl)
tag :: forall cl. TimeInfo cl -> Tag cl
absolute :: forall cl. TimeInfo cl -> Time cl
sinceInit :: forall cl. TimeInfo cl -> Diff (Time cl)
sinceLast :: forall cl. TimeInfo cl -> Diff (Time cl)
..} <- forall (m :: Type -> Type) cl a.
Monad m =>
ClSF m cl a (TimeInfo cl)
timeInfo -< ()
forall (a :: Type -> Type -> Type) b. Arrow a => a b b
returnA -< (v
v forall v a. VectorSpace v a => v -> v -> v
^-^ v
vLast) forall v a. VectorSpace v a => v -> a -> v
^/ Diff (Time cl)
sinceLast
derivative ::
( Monad m
, VectorSpace v s
, s ~ Diff td
) =>
BehaviorF m td v v
derivative :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
BehaviorF m td v v
derivative = forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> BehaviorF m td v v
derivativeFrom forall v a. VectorSpace v a => v
zeroVector
threePointDerivativeFrom ::
( Monad m
, VectorSpace v s
, s ~ Diff td
) =>
v ->
BehaviorF m td v v
threePointDerivativeFrom :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> BehaviorF m td v v
threePointDerivativeFrom v
v0 = proc v
v -> do
v
dv <- forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> BehaviorF m td v v
derivativeFrom v
v0 -< v
v
v
dv' <- forall (m :: Type -> Type) a. Monad m => a -> MSF m a a
iPre forall v a. VectorSpace v a => v
zeroVector -< v
dv
forall (a :: Type -> Type -> Type) b. Arrow a => a b b
returnA -< (v
dv forall v a. VectorSpace v a => v -> v -> v
^+^ v
dv') forall v a. VectorSpace v a => v -> a -> v
^/ s
2
threePointDerivative ::
( Monad m
, VectorSpace v s
, s ~ Diff td
) =>
BehaviorF m td v v
threePointDerivative :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
BehaviorF m td v v
threePointDerivative = forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> BehaviorF m td v v
threePointDerivativeFrom forall v a. VectorSpace v a => v
zeroVector
weightedAverageFrom ::
( Monad m
, VectorSpace v s
, s ~ Diff td
) =>
v ->
BehaviorF m td (v, s) v
weightedAverageFrom :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> BehaviorF m td (v, s) v
weightedAverageFrom v
v0 = forall (m :: Type -> Type) c a b.
Monad m =>
c -> MSF m (a, c) (b, c) -> MSF m a b
feedback v
v0 forall a b. (a -> b) -> a -> b
$ proc ((v
v, s
weight), v
vAvg) -> do
let
vAvg' :: v
vAvg' = s
weight forall v a. VectorSpace v a => a -> v -> v
*^ v
vAvg forall v a. VectorSpace v a => v -> v -> v
^+^ (s
1 forall a. Num a => a -> a -> a
- s
weight) forall v a. VectorSpace v a => a -> v -> v
*^ v
v
forall (a :: Type -> Type -> Type) b. Arrow a => a b b
returnA -< (v
vAvg', v
vAvg')
averageFrom ::
( Monad m
, VectorSpace v s
, Floating s
, s ~ Diff td
) =>
v ->
Diff td ->
BehaviorF m td v v
averageFrom :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
v -> Diff td -> BehaviorF m td v v
averageFrom v
v0 Diff td
t = proc v
v -> do
TimeInfo {Diff (Time cl)
Time cl
Tag cl
tag :: Tag cl
absolute :: Time cl
sinceInit :: Diff (Time cl)
sinceLast :: Diff (Time cl)
tag :: forall cl. TimeInfo cl -> Tag cl
absolute :: forall cl. TimeInfo cl -> Time cl
sinceInit :: forall cl. TimeInfo cl -> Diff (Time cl)
sinceLast :: forall cl. TimeInfo cl -> Diff (Time cl)
..} <- forall (m :: Type -> Type) cl a.
Monad m =>
ClSF m cl a (TimeInfo cl)
timeInfo -< ()
let
weight :: s
weight = forall a. Floating a => a -> a
exp forall a b. (a -> b) -> a -> b
$ -(Diff (Time cl)
sinceLast forall a. Fractional a => a -> a -> a
/ Diff td
t)
forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> BehaviorF m td (v, s) v
weightedAverageFrom v
v0 -< (v
v, s
weight)
average ::
( Monad m
, VectorSpace v s
, Floating s
, s ~ Diff td
) =>
Diff td ->
BehaviourF m td v v
average :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
average = forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
v -> Diff td -> BehaviorF m td v v
averageFrom forall v a. VectorSpace v a => v
zeroVector
averageLinFrom ::
( Monad m
, VectorSpace v s
, s ~ Diff td
) =>
v ->
Diff td ->
BehaviourF m td v v
averageLinFrom :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> Diff td -> BehaviourF m td v v
averageLinFrom v
v0 Diff td
t = proc v
v -> do
TimeInfo {Diff (Time cl)
Time cl
Tag cl
tag :: Tag cl
absolute :: Time cl
sinceInit :: Diff (Time cl)
sinceLast :: Diff (Time cl)
tag :: forall cl. TimeInfo cl -> Tag cl
absolute :: forall cl. TimeInfo cl -> Time cl
sinceInit :: forall cl. TimeInfo cl -> Diff (Time cl)
sinceLast :: forall cl. TimeInfo cl -> Diff (Time cl)
..} <- forall (m :: Type -> Type) cl a.
Monad m =>
ClSF m cl a (TimeInfo cl)
timeInfo -< ()
let
weight :: s
weight = Diff td
t forall a. Fractional a => a -> a -> a
/ (Diff (Time cl)
sinceLast forall a. Num a => a -> a -> a
+ Diff td
t)
forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> BehaviorF m td (v, s) v
weightedAverageFrom v
v0 -< (v
v, s
weight)
averageLin ::
( Monad m
, VectorSpace v s
, s ~ Diff td
) =>
Diff td ->
BehaviourF m td v v
averageLin :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
averageLin = forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, s ~ Diff td) =>
v -> Diff td -> BehaviourF m td v v
averageLinFrom forall v a. VectorSpace v a => v
zeroVector
lowPass ::
( Monad m
, VectorSpace v s
, Floating s
, s ~ Diff td
) =>
Diff td ->
BehaviourF m td v v
lowPass :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
lowPass = forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
average
highPass ::
( Monad m
, VectorSpace v s
, Floating s
, s ~ Diff td
) =>
Diff td ->
BehaviourF m td v v
highPass :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
highPass Diff td
t = forall (m :: Type -> Type) cl a. Monad m => ClSF m cl a a
clId forall v a. VectorSpace v a => v -> v -> v
^-^ forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
lowPass Diff td
t
bandPass ::
( Monad m
, VectorSpace v s
, Floating s
, s ~ Diff td
) =>
Diff td ->
BehaviourF m td v v
bandPass :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
bandPass Diff td
t = forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
lowPass Diff td
t forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
highPass Diff td
t
bandStop ::
( Monad m
, VectorSpace v s
, Floating s
, s ~ Diff td
) =>
Diff td ->
BehaviourF m td v v
bandStop :: forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
bandStop Diff td
t = forall (m :: Type -> Type) cl a. Monad m => ClSF m cl a a
clId forall v a. VectorSpace v a => v -> v -> v
^-^ forall (m :: Type -> Type) v s td.
(Monad m, VectorSpace v s, Floating s, s ~ Diff td) =>
Diff td -> BehaviourF m td v v
bandPass Diff td
t
keepFirst :: Monad m => ClSF m cl a a
keepFirst :: forall (m :: Type -> Type) cl a. Monad m => ClSF m cl a a
keepFirst = forall (m :: Type -> Type) a b.
Monad m =>
MSFExcept m a b Void -> MSF m a b
safely forall a b. (a -> b) -> a -> b
$ do
a
a <- forall (m :: Type -> Type) e cl a b.
Monad m =>
ClSF (ExceptT e m) cl a b -> ClSFExcept m cl a b e
try forall (m :: Type -> Type) e cl a.
Monad m =>
ClSF (ExceptT e m) cl e a
throwS
forall (m :: Type -> Type) a b e.
Monad m =>
MSF m a b -> MSFExcept m a b e
safe forall a b. (a -> b) -> a -> b
$ forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr forall a b. (a -> b) -> a -> b
$ forall a b. a -> b -> a
const a
a
historySince ::
(Monad m, Ord (Diff (Time cl)), TimeDomain (Time cl)) =>
Diff (Time cl) ->
ClSF m cl a (Seq (TimeInfo cl, a))
historySince :: forall (m :: Type -> Type) cl a.
(Monad m, Ord (Diff (Time cl)), TimeDomain (Time cl)) =>
Diff (Time cl) -> ClSF m cl a (Seq (TimeInfo cl, a))
historySince Diff (Time cl)
dTime = forall (m :: Type -> Type) r a b.
Monad m =>
MSF m (r, a) b -> MSF (ReaderT r m) a b
readerS forall a b. (a -> b) -> a -> b
$ forall (m :: Type -> Type) a s.
Monad m =>
(a -> s -> s) -> s -> MSF m a s
accumulateWith (TimeInfo cl, a) -> Seq (TimeInfo cl, a) -> Seq (TimeInfo cl, a)
appendValue forall a. Seq a
empty
where
appendValue :: (TimeInfo cl, a) -> Seq (TimeInfo cl, a) -> Seq (TimeInfo cl, a)
appendValue (TimeInfo cl
ti, a
a) Seq (TimeInfo cl, a)
tias = forall a. (a -> Bool) -> Seq a -> Seq a
takeWhileL (TimeInfo cl -> (TimeInfo cl, a) -> Bool
recentlySince TimeInfo cl
ti) forall a b. (a -> b) -> a -> b
$ (TimeInfo cl
ti, a
a) forall a. a -> Seq a -> Seq a
<| Seq (TimeInfo cl, a)
tias
recentlySince :: TimeInfo cl -> (TimeInfo cl, a) -> Bool
recentlySince TimeInfo cl
ti (TimeInfo cl
ti', a
_) = forall time. TimeDomain time => time -> time -> Diff time
diffTime (forall cl. TimeInfo cl -> Time cl
absolute TimeInfo cl
ti) (forall cl. TimeInfo cl -> Time cl
absolute TimeInfo cl
ti') forall a. Ord a => a -> a -> Bool
< Diff (Time cl)
dTime
delayBy ::
(Monad m, Ord (Diff td), TimeDomain td) =>
Diff td ->
BehaviorF m td a a
delayBy :: forall (m :: Type -> Type) td a.
(Monad m, Ord (Diff td), TimeDomain td) =>
Diff td -> BehaviorF m td a a
delayBy Diff td
dTime = forall (m :: Type -> Type) cl a.
(Monad m, Ord (Diff (Time cl)), TimeDomain (Time cl)) =>
Diff (Time cl) -> ClSF m cl a (Seq (TimeInfo cl, a))
historySince Diff td
dTime forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr (forall a. Seq a -> ViewR a
viewr forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall {a}. ViewR a -> Maybe a
safeHead) forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall (m :: Type -> Type) a. Monad m => a -> MSF m (Maybe a) a
lastS forall a. HasCallStack => a
undefined forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr forall a b. (a, b) -> b
snd
where
safeHead :: ViewR a -> Maybe a
safeHead ViewR a
EmptyR = forall a. Maybe a
Nothing
safeHead (Seq a
_ :> a
a) = forall a. a -> Maybe a
Just a
a
timer ::
( Monad m
, TimeDomain td
, Ord (Diff td)
) =>
Diff td ->
BehaviorF (ExceptT () m) td a (Diff td)
timer :: forall (m :: Type -> Type) td a.
(Monad m, TimeDomain td, Ord (Diff td)) =>
Diff td -> BehaviorF (ExceptT () m) td a (Diff td)
timer Diff td
diff = proc a
_ -> do
Diff td
time <- forall (m :: Type -> Type) time a.
(Monad m, TimeDomain time) =>
BehaviourF m time a (Diff time)
sinceStart -< ()
()
_ <- forall (m :: Type -> Type) e cl.
Monad m =>
e -> ClSF (ExceptT e m) cl Bool ()
throwOn () -< Diff td
time forall a. Ord a => a -> a -> Bool
> Diff td
diff
forall (a :: Type -> Type -> Type) b. Arrow a => a b b
returnA -< Diff td
time
timer_ ::
( Monad m
, TimeDomain td
, Ord (Diff td)
) =>
Diff td ->
BehaviorF (ExceptT () m) td a ()
timer_ :: forall (m :: Type -> Type) td a.
(Monad m, TimeDomain td, Ord (Diff td)) =>
Diff td -> BehaviorF (ExceptT () m) td a ()
timer_ Diff td
diff = forall (m :: Type -> Type) td a.
(Monad m, TimeDomain td, Ord (Diff td)) =>
Diff td -> BehaviorF (ExceptT () m) td a (Diff td)
timer Diff td
diff forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr (forall a b. a -> b -> a
const ())
scaledTimer ::
( Monad m
, TimeDomain td
, Fractional (Diff td)
, Ord (Diff td)
) =>
Diff td ->
BehaviorF (ExceptT () m) td a (Diff td)
scaledTimer :: forall (m :: Type -> Type) td a.
(Monad m, TimeDomain td, Fractional (Diff td), Ord (Diff td)) =>
Diff td -> BehaviorF (ExceptT () m) td a (Diff td)
scaledTimer Diff td
diff = forall (m :: Type -> Type) td a.
(Monad m, TimeDomain td, Ord (Diff td)) =>
Diff td -> BehaviorF (ExceptT () m) td a (Diff td)
timer Diff td
diff forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr (forall a. Fractional a => a -> a -> a
/ Diff td
diff)
lastS :: Monad m => a -> MSF m (Maybe a) a
lastS :: forall (m :: Type -> Type) a. Monad m => a -> MSF m (Maybe a) a
lastS a
a = forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr forall a. Maybe a -> Last a
Last forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall n (m :: Type -> Type). (Monoid n, Monad m) => n -> MSF m n n
mappendFrom (forall a. Maybe a -> Last a
Last (forall a. a -> Maybe a
Just a
a)) forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall (a :: Type -> Type -> Type) b c.
Arrow a =>
(b -> c) -> a b c
arr (forall a. Last a -> Maybe a
getLast forall {k} (cat :: k -> k -> Type) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall a. HasCallStack => Maybe a -> a
fromJust)