Skip to content

Commit

Permalink
Merge pull request #279 from turion/sundry
Browse files Browse the repository at this point in the history
Sundry
  • Loading branch information
turion authored Apr 18, 2024
2 parents 59a1396 + b51cde8 commit a0fd29f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 43 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ would be:
* `rhine/`: The main library, which is also mirrored on hackage.
* `rhine-gloss/`: A wrapper library to [`gloss`](https://hackage.haskell.org/package/gloss), a functional OpenGL library.
* `rhine-bayes/`: A library for stochastic processes and online machine learning, using [`monad-bayes`](https://hackage.haskell.org/package/monad-bayes).
* `rhine-terminal/`: A wrapper library to [`terminal`](https://hackage.haskell.org/package/terminal), a library to write terminal applications.
* `rhine-examples/`: Different examples as a starting point to learn Rhine.

## Documentation
Expand Down
2 changes: 1 addition & 1 deletion rhine-bayes/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ glossClockUTC cl =
}

{- | The part of the program which simulates latent position and sensor,
running 100 times a second.
running 10 times a second.
-}
modelRhine :: Rhine (GlossConcT IO) (LiftClock IO GlossConcT (Millisecond 100)) Temperature (Temperature, (Sensor, Pos))
modelRhine = hoistClSF sampleIOGloss (clId &&& genModelWithoutTemperature) @@ liftClock waitClock
Expand Down
2 changes: 1 addition & 1 deletion rhine/rhine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ library
FRP.Rhine.Reactimation.ClockErasure
FRP.Rhine.Reactimation.Combinators
FRP.Rhine.ResamplingBuffer
FRP.Rhine.ResamplingBuffer.ClSF
FRP.Rhine.ResamplingBuffer.Collect
FRP.Rhine.ResamplingBuffer.FIFO
FRP.Rhine.ResamplingBuffer.Interpolation
FRP.Rhine.ResamplingBuffer.KeepLast
FRP.Rhine.ResamplingBuffer.LIFO
FRP.Rhine.ResamplingBuffer.MSF
FRP.Rhine.ResamplingBuffer.Timeless
FRP.Rhine.ResamplingBuffer.Util
FRP.Rhine.SN
Expand Down
2 changes: 1 addition & 1 deletion rhine/src/FRP/Rhine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ import FRP.Rhine.Clock.Select as X
import FRP.Rhine.Clock.Trivial as X
import FRP.Rhine.Clock.Unschedule as X

import FRP.Rhine.ResamplingBuffer.ClSF as X
import FRP.Rhine.ResamplingBuffer.Collect as X
import FRP.Rhine.ResamplingBuffer.FIFO as X
import FRP.Rhine.ResamplingBuffer.Interpolation as X
import FRP.Rhine.ResamplingBuffer.KeepLast as X
import FRP.Rhine.ResamplingBuffer.LIFO as X
import FRP.Rhine.ResamplingBuffer.MSF as X
import FRP.Rhine.ResamplingBuffer.Timeless as X
44 changes: 44 additions & 0 deletions rhine/src/FRP/Rhine/ResamplingBuffer/ClSF.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{-# LANGUAGE RecordWildCards #-}

{- |
Collect and process all incoming values statefully and with time stamps.
-}
module FRP.Rhine.ResamplingBuffer.ClSF where

-- transformers
import Control.Monad.Trans.Reader (runReaderT)

-- dunai
import Data.MonadicStreamFunction.InternalCore (unMSF)

-- rhine
import FRP.Rhine.ClSF.Core
import FRP.Rhine.ResamplingBuffer

{- | Given a clocked signal function that accepts
a varying number of timestamped inputs (a list),
a `ResamplingBuffer` can be formed
that collects all this input and steps the signal function
whenever output is requested.
-}
clsfBuffer ::
(Monad m) =>
-- | The clocked signal function that consumes
-- and a list of timestamped inputs,
-- and outputs a single value.
-- The list will contain the /newest/ element in the head.
ClSF m cl2 [(TimeInfo cl1, a)] b ->
ResamplingBuffer m cl1 cl2 a b
clsfBuffer = clsfBuffer' []
where
clsfBuffer' ::
(Monad m) =>
[(TimeInfo cl1, a)] ->
ClSF m cl2 [(TimeInfo cl1, a)] b ->
ResamplingBuffer m cl1 cl2 a b
clsfBuffer' as msf = ResamplingBuffer {..}
where
put ti1 a = return $ clsfBuffer' ((ti1, a) : as) msf
get ti2 = do
(b, msf') <- runReaderT (unMSF msf as) ti2
return (b, clsfBuffer msf')
40 changes: 0 additions & 40 deletions rhine/src/FRP/Rhine/ResamplingBuffer/MSF.hs

This file was deleted.

0 comments on commit a0fd29f

Please sign in to comment.