Skip to content

Commit

Permalink
Inlines
Browse files Browse the repository at this point in the history
  • Loading branch information
turion committed Nov 27, 2024
1 parent da8c043 commit c1a83ee
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 ::
Expand All @@ -59,6 +60,7 @@ synchronous ::
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 @@ -101,11 +103,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 @@ -114,6 +118,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 @@ -122,6 +127,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 @@ -143,6 +149,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 c1a83ee

Please sign in to comment.