Skip to content

Commit

Permalink
Inlines
Browse files Browse the repository at this point in the history
  • Loading branch information
turion committed Aug 8, 2024
1 parent 776fb85 commit cf8b942
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rhine/src/FRP/Rhine/Reactimation/ClockErasure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ instance GetClockProxy cl => ToClockProxy (SN m cl a b) where

eraseClockSN :: Time cl -> SN m cl a b -> (Automaton m (Time cl, Tag cl, Maybe a) (Maybe b))
eraseClockSN time = flip runReader time . getSN
{-# INLINE eraseClockSN #-}

-- A synchronous signal network is run by erasing the clock from the clocked signal function.
synchronous :: forall cl m a b . ( cl ~ In cl, cl ~ Out cl, Monad m, Clock m cl, GetClockProxy cl) =>
Expand All @@ -58,6 +59,7 @@ synchronous :: forall cl m a b . ( cl ~ In cl, cl ~ Out cl, Monad m, Clock m
synchronous clsf = SN $ reader $ \initialTime -> proc (time, tag, Just a) -> do
b <- eraseClockClSF (getClockProxy @cl) initialTime clsf -< (time, tag, a)
returnA -< Just b
{-# INLINE synchronous #-}

-- A sequentially composed signal network may either be triggered in its first component,
-- or its second component. In either case,
Expand Down Expand Up @@ -94,11 +96,13 @@ sequential sn1 resBuf sn2 = SN $ reader $ \initialTime ->
returnA -< Nothing
Right tagR -> do
eraseClockSN initialTime sn2 -< (time, tagR, join maybeC)
{-# INLINE sequential #-}

parallel snL snR = SN $ reader$ \initialTime -> proc (time, tag, maybeA) -> do
case tag of
Left tagL -> eraseClockSN initialTime snL -< (time, tagL, maybeA)
Right tagR -> eraseClockSN initialTime snR -< (time, tagR, maybeA)
{-# INLINE parallel #-}

postcompose sn clsf = SN $ reader $ \initialTime ->
let
Expand All @@ -107,6 +111,7 @@ postcompose sn clsf = SN $ reader $ \initialTime ->
proc input@(time, tag, _) -> do
bMaybe <- eraseClockSN initialTime sn -< input
mapMaybeS $ eraseClockClSF (outProxy proxy) initialTime clsf -< (time,,) <$> outTag proxy tag <*> bMaybe
{-# INLINE postcompose #-}

precompose clsf sn = SN $ reader $ \initialTime ->
let
Expand All @@ -115,6 +120,7 @@ precompose clsf sn = SN $ reader $ \initialTime ->
proc (time, tag, aMaybe) -> do
bMaybe <- mapMaybeS $ eraseClockClSF (inProxy proxy) initialTime clsf -< (time,,) <$> inTag proxy tag <*> aMaybe
eraseClockSN initialTime sn -< (time, tag, bMaybe)
{-# INLINE precompose #-}

feedbackSN ResamplingBuffer {buffer, put, get} sn = SN $ reader $ \initialTime ->
let
Expand All @@ -136,6 +142,8 @@ feedbackSN ResamplingBuffer {buffer, put, get} sn = SN $ reader $ \initialTime
timeInfo <- genTimeInfo (outProxy proxy) initialTime -< (time, tagOut)
buf'' <- arrM $ uncurry $ uncurry put -< ((timeInfo, d), buf')
returnA -< (Just b, buf'')
{-# INLINE feedbackSN #-}

firstResampling sn buf = SN $ reader $ \initialTime ->
let
proxy = toClockProxy sn
Expand Down

0 comments on commit cf8b942

Please sign in to comment.