packages feed

rhine 1.0 → 1.1

raw patch · 27 files changed

+108/−94 lines, 27 filesdep ~dunaidep ~monad-scheduledep ~simple-affine-space

Dependency ranges changed: dunai, monad-schedule, simple-affine-space, time-domain

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for rhine +## 1.1++* dunai-0.11 compatibility+ ## 1.0  * Removed schedules. See the [page about changes in version 1](/version1.md).
rhine.cabal view
@@ -2,7 +2,7 @@  name:                rhine -version:             1.0+version:             1.1  synopsis: Functional Reactive Programming with type-level clocks @@ -129,7 +129,7 @@    -- Other library packages from which modules are imported.   build-depends:-                     , dunai        ^>= 0.9+                     , dunai        ^>= 0.11                      , transformers >= 0.5                      , time         >= 1.8                      , free         >= 5.1@@ -137,10 +137,9 @@                      , deepseq      >= 1.4                      , random       >= 1.1                      , MonadRandom  >= 0.5-                     -- Remove version pin when https://github.com/ivanperez-keera/dunai/issues/298 is resolved:-                     , simple-affine-space == 0.1.1-                     , time-domain-                     , monad-schedule >= 0.1.2+                     , simple-affine-space ^>= 0.2+                     , time-domain ^>= 0.1.0.2+                     , monad-schedule ^>= 0.1.2    -- Directories containing source files.   hs-source-dirs:      src
src/FRP/Rhine/ClSF/Core.hs view
@@ -45,7 +45,7 @@    that doesn't depend on a particular clock.    @time@ denotes the 'TimeDomain'. -}-type Behaviour m time a = forall cl. time ~ Time cl => ClSignal m cl a+type Behaviour m time a = forall cl. (time ~ Time cl) => ClSignal m cl a  -- | Compatibility to U.S. american spelling. type Behavior m time a = Behaviour m time a@@ -54,7 +54,7 @@    function that doesn't depend on a particular clock.    @time@ denotes the 'TimeDomain'. -}-type BehaviourF m time a b = forall cl. time ~ Time cl => ClSF m cl a b+type BehaviourF m time a b = forall cl. (time ~ Time cl) => ClSF m cl a b  -- | Compatibility to U.S. american spelling. type BehaviorF m time a b = BehaviourF m time a b@@ -95,15 +95,15 @@ {- | A monadic stream function without dependency on time    is a 'ClSF' for any clock. -}-timeless :: Monad m => MSF m a b -> ClSF m cl a b+timeless :: (Monad m) => MSF m a b -> ClSF m cl a b timeless = liftTransS  -- | Utility to lift Kleisli arrows directly to 'ClSF's.-arrMCl :: Monad m => (a -> m b) -> ClSF m cl a b+arrMCl :: (Monad m) => (a -> m b) -> ClSF m cl a b arrMCl = timeless . arrM  -- | Version without input.-constMCl :: Monad m => m b -> ClSF m cl a b+constMCl :: (Monad m) => m b -> ClSF m cl a b constMCl = timeless . constM  {- | Call a 'ClSF' every time the input is 'Just a'.@@ -117,7 +117,7 @@ whereas the latter always returns the correct time since initialisation. -} mapMaybe ::-  Monad m =>+  (Monad m) =>   ClSF m cl a b ->   ClSF m cl (Maybe a) (Maybe b) mapMaybe behaviour = proc ma -> case ma of
src/FRP/Rhine/ClSF/Except.hs view
@@ -42,30 +42,30 @@ -- * Throwing exceptions  -- | Immediately throw the incoming exception.-throwS :: Monad m => ClSF (ExceptT e m) cl e a+throwS :: (Monad m) => ClSF (ExceptT e m) cl e a throwS = arrMCl throwE  -- | Immediately throw the given exception.-throw :: Monad m => e -> MSF (ExceptT e m) a b+throw :: (Monad m) => e -> MSF (ExceptT e m) a b throw = constM . throwE  -- | Do not throw an exception.-pass :: Monad m => MSF (ExceptT e m) a a+pass :: (Monad m) => MSF (ExceptT e m) a a pass = Category.id  -- | Throw the given exception when the 'Bool' turns true.-throwOn :: Monad m => e -> ClSF (ExceptT e m) cl Bool ()+throwOn :: (Monad m) => e -> ClSF (ExceptT e m) cl Bool () throwOn e = proc b -> throwOn' -< (b, e)  -- | Variant of 'throwOn', where the exception can vary every tick.-throwOn' :: Monad m => ClSF (ExceptT e m) cl (Bool, e) ()+throwOn' :: (Monad m) => ClSF (ExceptT e m) cl (Bool, e) () throwOn' = proc (b, e) ->   if b     then throwS -< e     else returnA -< ()  -- | Throw the exception 'e' whenever the function evaluates to 'True'.-throwOnCond :: Monad m => (a -> Bool) -> e -> ClSF (ExceptT e m) cl a a+throwOnCond :: (Monad m) => (a -> Bool) -> e -> ClSF (ExceptT e m) cl a a throwOnCond cond e = proc a ->   if cond a     then throwS -< e@@ -74,7 +74,7 @@ {- | Variant of 'throwOnCond' for Kleisli arrows.    Throws the exception when the input is 'True'. -}-throwOnCondM :: Monad m => (a -> m Bool) -> e -> ClSF (ExceptT e m) cl a a+throwOnCondM :: (Monad m) => (a -> m Bool) -> e -> ClSF (ExceptT e m) cl a a throwOnCondM cond e = proc a -> do   b <- arrMCl (lift . cond) -< a   if b@@ -82,7 +82,7 @@     else returnA -< a  -- | When the input is @Just e@, throw the exception @e@.-throwMaybe :: Monad m => ClSF (ExceptT e m) cl (Maybe e) (Maybe a)+throwMaybe :: (Monad m) => ClSF (ExceptT e m) cl (Maybe e) (Maybe a) throwMaybe = proc me -> case me of   Nothing -> returnA -< Nothing   Just e -> throwS -< e@@ -109,34 +109,34 @@ Any clock with time domain @time@ may occur. -} type BehaviourFExcept m time a b e =-  forall cl. time ~ Time cl => ClSFExcept m cl a b e+  forall cl. (time ~ Time cl) => ClSFExcept m cl a b e  -- | Compatibility to U.S. american spelling. type BehaviorFExcept m time a b e = BehaviourFExcept m time a b e  -- | Leave the monad context, to use the 'ClSFExcept' as an 'Arrow'.-runClSFExcept :: Monad m => ClSFExcept m cl a b e -> ClSF (ExceptT e m) cl a b+runClSFExcept :: (Monad m) => ClSFExcept m cl a b e -> ClSF (ExceptT e m) cl a b runClSFExcept = morphS commuteExceptReader . runMSFExcept  {- | Enter the monad context in the exception    for 'ClSF's in the 'ExceptT' monad.    The 'ClSF' will be run until it encounters an exception. -}-try :: Monad m => ClSF (ExceptT e m) cl a b -> ClSFExcept m cl a b e+try :: (Monad m) => ClSF (ExceptT e m) cl a b -> ClSFExcept m cl a b e try = MSFE.try . morphS commuteReaderExcept  {- | Within the same tick, perform a monadic action,    and immediately throw the value as an exception. -}-once :: Monad m => (a -> m e) -> ClSFExcept m cl a b e+once :: (Monad m) => (a -> m e) -> ClSFExcept m cl a b e once f = MSFE.once $ lift . f  -- | A variant of 'once' without input.-once_ :: Monad m => m e -> ClSFExcept m cl a b e+once_ :: (Monad m) => m e -> ClSFExcept m cl a b e once_ = once . const  {- | Advances a single tick with the given Kleisli arrow,    and then throws an exception. -}-step :: Monad m => (a -> m (b, e)) -> ClSFExcept m cl a b e+step :: (Monad m) => (a -> m (b, e)) -> ClSFExcept m cl a b e step f = MSFE.step $ lift . f
src/FRP/Rhine/ClSF/Random.hs view
@@ -58,14 +58,14 @@  -- | Evaluates the random computation by using the global random generator. evalRandIOS ::-  Monad m =>+  (Monad m) =>   ClSF (RandT StdGen m) cl a b ->   IO (ClSF m cl a b) evalRandIOS clsf = evalRandS clsf <$> newStdGen  -- | Evaluates the random computation by using the global random generator on the first tick. evalRandIOS' ::-  MonadIO m =>+  (MonadIO m) =>   ClSF (RandT StdGen m) cl a b ->   ClSF m cl a b evalRandIOS' = performOnFirstSample . liftIO . evalRandIOS
src/FRP/Rhine/ClSF/Reader.hs view
@@ -29,7 +29,7 @@    by passing the original behaviour the extra @r@ input. -} readerS ::-  Monad m =>+  (Monad m) =>   ClSF m cl (a, r) b ->   ClSF (ReaderT r m) cl a b readerS behaviour =@@ -39,7 +39,7 @@    by making it an explicit input to the behaviour. -} runReaderS ::-  Monad m =>+  (Monad m) =>   ClSF (ReaderT r m) cl a b ->   ClSF m cl (a, r) b runReaderS behaviour =@@ -47,7 +47,7 @@  -- | Remove a 'ReaderT' layer by passing the readonly environment explicitly. runReaderS_ ::-  Monad m =>+  (Monad m) =>   ClSF (ReaderT r m) cl a b ->   r ->   ClSF m cl a b
src/FRP/Rhine/ClSF/Upsample.hs view
@@ -18,7 +18,7 @@    that cause it to tick without doing anything    and replicating the last output. -}-upsampleMSF :: Monad m => b -> MSF m a b -> MSF m (Either arbitrary a) b+upsampleMSF :: (Monad m) => b -> MSF m a b -> MSF m (Either arbitrary a) b upsampleMSF b msf = right msf >>> accumulateWith (<>) (Right b) >>> arr fromRight   where     fromRight (Right b') = b'
src/FRP/Rhine/ClSF/Util.hs view
@@ -27,6 +27,7 @@  -- dunai import Control.Monad.Trans.MSF.Reader (readerS)+import Data.MonadicStreamFunction.Instances.Num () import Data.MonadicStreamFunction.Instances.VectorSpace ()  -- simple-affine-space@@ -40,7 +41,7 @@ -- * Read time information  -- | Read the environment variable, i.e. the 'TimeInfo'.-timeInfo :: Monad m => ClSF m cl a (TimeInfo cl)+timeInfo :: (Monad m) => ClSF m cl a (TimeInfo cl) timeInfo = constM ask  {- | Utility to apply functions to the current 'TimeInfo',@@ -50,23 +51,23 @@ printAbsoluteTime = timeInfoOf absolute >>> arrMCl print @ -}-timeInfoOf :: Monad m => (TimeInfo cl -> b) -> ClSF m cl a b+timeInfoOf :: (Monad m) => (TimeInfo cl -> b) -> ClSF m cl a b timeInfoOf f = constM $ asks f  -- | Continuously return the time difference since the last tick.-sinceLastS :: Monad m => ClSF m cl a (Diff (Time cl))+sinceLastS :: (Monad m) => ClSF m cl a (Diff (Time cl)) sinceLastS = timeInfoOf sinceLast  -- | Continuously return the time difference since clock initialisation.-sinceInitS :: Monad m => ClSF m cl a (Diff (Time cl))+sinceInitS :: (Monad m) => ClSF m cl a (Diff (Time cl)) sinceInitS = timeInfoOf sinceInit  -- | Continuously return the absolute time.-absoluteS :: Monad m => ClSF m cl a (Time cl)+absoluteS :: (Monad m) => ClSF m cl a (Time cl) absoluteS = timeInfoOf absolute  -- | Continuously return the tag of the current tick.-tagS :: Monad m => ClSF m cl a (Tag cl)+tagS :: (Monad m) => ClSF m cl a (Tag cl) tagS = timeInfoOf tag  {- |@@ -110,7 +111,7 @@ infixr 6 >->  (>->) ::-  Category cat =>+  (Category cat) =>   cat a b ->   cat b c ->   cat a c@@ -120,7 +121,7 @@ infixl 6 <-<  (<-<) ::-  Category cat =>+  (Category cat) =>   cat b c ->   cat a b ->   cat a c@@ -131,11 +132,11 @@  > arr_ :: Monad m => b -> ClSF m cl a b -}-arr_ :: Arrow a => b -> a c b+arr_ :: (Arrow a) => b -> a c b arr_ = arr . const  -- | The identity synchronous stream function.-clId :: Monad m => ClSF m cl a a+clId :: (Monad m) => ClSF m cl a a clId = Control.Category.id  -- * Basic signal processing components@@ -197,6 +198,7 @@   ( Monad m   , VectorSpace v s   , s ~ Diff td+  , Num s   ) =>   -- | The initial position   v ->@@ -213,6 +215,7 @@   ( Monad m   , VectorSpace v s   , s ~ Diff td+  , Num s   ) =>   BehaviorF m td v v threePointDerivative = threePointDerivativeFrom zeroVector@@ -231,6 +234,7 @@   ( Monad m   , VectorSpace v s   , s ~ Diff td+  , Num s   ) =>   -- | The initial position   v ->@@ -282,6 +286,7 @@ averageLinFrom ::   ( Monad m   , VectorSpace v s+  , Floating s   , s ~ Diff td   ) =>   -- | The initial position@@ -299,6 +304,7 @@ averageLin ::   ( Monad m   , VectorSpace v s+  , Floating s   , s ~ Diff td   ) =>   -- | The time scale on which the signal is averaged@@ -324,6 +330,7 @@   ( Monad m   , VectorSpace v s   , Floating s+  , Eq s   , s ~ Diff td   ) =>   -- | The time constant @t@@@ -336,6 +343,7 @@   ( Monad m   , VectorSpace v s   , Floating s+  , Eq s   , s ~ Diff td   ) =>   -- | The time constant @t@@@ -348,6 +356,7 @@   ( Monad m   , VectorSpace v s   , Floating s+  , Eq s   , s ~ Diff td   ) =>   -- | The time constant @t@@@ -358,7 +367,7 @@ -- * Delays  -- | Remembers and indefinitely outputs ("holds") the first input value.-keepFirst :: Monad m => ClSF m cl a a+keepFirst :: (Monad m) => ClSF m cl a a keepFirst = safely $ do   a <- try throwS   safe $ arr $ const a@@ -432,5 +441,5 @@ {- | Remembers the last 'Just' value,    defaulting to the given initialisation value. -}-lastS :: Monad m => a -> MSF m (Maybe a) a+lastS :: (Monad m) => a -> MSF m (Maybe a) a lastS a = arr Last >>> mappendFrom (Last (Just a)) >>> arr (getLast >>> fromJust)
src/FRP/Rhine/Clock.hs view
@@ -57,7 +57,7 @@ and only differ in implementation details. Often, clocks are singletons. -}-class TimeDomain (Time cl) => Clock m cl where+class (TimeDomain (Time cl)) => Clock m cl where   -- | The time domain, i.e. type of the time stamps the clock creates.   type Time cl @@ -125,7 +125,7 @@    although this type is ambiguous. -} rescaleMToSInit ::-  Monad m =>+  (Monad m) =>   (time1 -> m time2) ->   time1 ->   m (MSF m (time1, tag) (time2, tag), time2)@@ -177,7 +177,7 @@       )  -- | A 'RescaledClock' is trivially a 'RescaledClockM'.-rescaledClockToM :: Monad m => RescaledClock cl time -> RescaledClockM m cl time+rescaledClockToM :: (Monad m) => RescaledClock cl time -> RescaledClockM m cl time rescaledClockToM RescaledClock {..} =   RescaledClockM     { unscaledClockM = unscaledClock@@ -211,7 +211,7 @@  -- | A 'RescaledClockM' is trivially a 'RescaledClockS'. rescaledClockMToS ::-  Monad m =>+  (Monad m) =>   RescaledClockM m cl time ->   RescaledClockS m cl time (Tag cl) rescaledClockMToS RescaledClockM {..} =@@ -222,7 +222,7 @@  -- | A 'RescaledClock' is trivially a 'RescaledClockS'. rescaledClockToS ::-  Monad m =>+  (Monad m) =>   RescaledClock cl time ->   RescaledClockS m cl time (Tag cl) rescaledClockToS = rescaledClockMToS . rescaledClockToM@@ -263,7 +263,7 @@ type IOClock m cl = HoistClock IO m cl  -- | Lift a clock value into 'MonadIO'.-ioClock :: MonadIO m => cl -> IOClock m cl+ioClock :: (MonadIO m) => cl -> IOClock m cl ioClock unhoistedClock =   HoistClock     { monadMorphism = liftIO
src/FRP/Rhine/Clock/FixedStep.hs view
@@ -36,7 +36,7 @@    which prevents composition of signals at different rates. -} data FixedStep (n :: Nat) where-  FixedStep :: KnownNat n => FixedStep n -- TODO Does the constraint bring any benefit?+  FixedStep :: (KnownNat n) => FixedStep n -- TODO Does the constraint bring any benefit?  -- | Extract the type-level natural number as an integer. stepsize :: FixedStep n -> Integer
src/FRP/Rhine/Clock/Periodic.hs view
@@ -60,7 +60,7 @@ data HeadClProxy (n :: Nat) where   HeadClProxy :: Periodic (n : ns) -> HeadClProxy n -headCl :: KnownNat n => Periodic (n : ns) -> Integer+headCl :: (KnownNat n) => Periodic (n : ns) -> Integer headCl cl = natVal $ HeadClProxy cl  tailCl :: Periodic (n1 : n2 : ns) -> Periodic (n2 : ns)@@ -69,7 +69,7 @@ class NonemptyNatList (v :: [Nat]) where   theList :: Periodic v -> NonEmpty Integer -instance KnownNat n => NonemptyNatList '[n] where+instance (KnownNat n) => NonemptyNatList '[n] where   theList cl = headCl cl :| []  instance@@ -83,7 +83,7 @@ -- TODO Port back to dunai when naming issues are resolved  -- | Repeatedly outputs the values of a given list, in order.-cycleS :: Monad m => NonEmpty a -> MSF m () a+cycleS :: (Monad m) => NonEmpty a -> MSF m () a cycleS as = unfold (second (fromMaybe as) . uncons) as  {-
src/FRP/Rhine/Clock/Proxy.hs view
@@ -75,10 +75,10 @@ instance (GetClockProxy cl1, GetClockProxy cl2) => GetClockProxy (ParallelClock cl1 cl2) where   getClockProxy = ParallelProxy getClockProxy getClockProxy -instance GetClockProxy cl => GetClockProxy (HoistClock m1 m2 cl)-instance GetClockProxy cl => GetClockProxy (RescaledClock cl time)-instance GetClockProxy cl => GetClockProxy (RescaledClockM m cl time)-instance GetClockProxy cl => GetClockProxy (RescaledClockS m cl time tag)+instance (GetClockProxy cl) => GetClockProxy (HoistClock m1 m2 cl)+instance (GetClockProxy cl) => GetClockProxy (RescaledClock cl time)+instance (GetClockProxy cl) => GetClockProxy (RescaledClockM m cl time)+instance (GetClockProxy cl) => GetClockProxy (RescaledClockS m cl time tag)  -- | Extract a clock proxy from a type. class ToClockProxy a where@@ -86,7 +86,7 @@    toClockProxy :: a -> ClockProxy (Cl a)   default toClockProxy ::-    GetClockProxy (Cl a) =>+    (GetClockProxy (Cl a)) =>     a ->     ClockProxy (Cl a)   toClockProxy _ = getClockProxy
src/FRP/Rhine/Clock/Realtime/Audio.hs view
@@ -42,7 +42,7 @@   | Hz96000  -- | Converts an 'AudioRate' to its corresponding rate as an 'Integral'.-rateToIntegral :: Integral a => AudioRate -> a+rateToIntegral :: (Integral a) => AudioRate -> a rateToIntegral Hz44100 = 44100 rateToIntegral Hz48000 = 48000 rateToIntegral Hz96000 = 96000@@ -70,9 +70,9 @@  class AudioClockRate (rate :: AudioRate) where   theRate :: AudioClock rate bufferSize -> AudioRate-  theRateIntegral :: Integral a => AudioClock rate bufferSize -> a+  theRateIntegral :: (Integral a) => AudioClock rate bufferSize -> a   theRateIntegral = rateToIntegral . theRate-  theRateNum :: Num a => AudioClock rate bufferSize -> a+  theRateNum :: (Num a) => AudioClock rate bufferSize -> a   theRateNum = fromInteger . theRateIntegral  instance AudioClockRate Hz44100 where@@ -104,7 +104,7 @@           round (10 ^ (12 :: Integer) / theRateNum audioClock :: Double)       bufferSize = theBufferSize audioClock -      runningClock :: MonadIO m => UTCTime -> Maybe Double -> MSF m () (UTCTime, Maybe Double)+      runningClock :: (MonadIO m) => UTCTime -> Maybe Double -> MSF m () (UTCTime, Maybe Double)       runningClock initialTime maybeWasLate = safely $ do         bufferFullTime <- try $ proc () -> do           n <- count -< ()@@ -136,9 +136,9 @@  class PureAudioClockRate (rate :: AudioRate) where   thePureRate :: PureAudioClock rate -> AudioRate-  thePureRateIntegral :: Integral a => PureAudioClock rate -> a+  thePureRateIntegral :: (Integral a) => PureAudioClock rate -> a   thePureRateIntegral = rateToIntegral . thePureRate-  thePureRateNum :: Num a => PureAudioClock rate -> a+  thePureRateNum :: (Num a) => PureAudioClock rate -> a   thePureRateNum = fromInteger . thePureRateIntegral  instance (Monad m, PureAudioClockRate rate) => Clock m (PureAudioClock rate) where
src/FRP/Rhine/Clock/Realtime/Event.hs view
@@ -71,7 +71,7 @@ Instead, create one @chan :: Chan c@, e.g. with 'newChan', and then use 'withChanS'. -}-runEventChanT :: MonadIO m => EventChanT event m a -> m a+runEventChanT :: (MonadIO m) => EventChanT event m a -> m a runEventChanT a = do   chan <- liftIO newChan   runReaderT a chan@@ -88,7 +88,7 @@ and, by using 'eventClockOn', to every clock that should tick on the event. -} withChanS ::-  Monad m =>+  (Monad m) =>   Chan event ->   ClSF (EventChanT event m) cl a b ->   ClSF m cl a b@@ -103,17 +103,17 @@ Nothing prevents you from emitting more events than are handled, causing the event buffer to grow indefinitely. -}-emit :: MonadIO m => event -> EventChanT event m ()+emit :: (MonadIO m) => event -> EventChanT event m () emit event = do   chan <- ask   liftIO $ writeChan chan event  -- | Emit an event on every tick.-emitS :: MonadIO m => ClSF (EventChanT event m) cl event ()+emitS :: (MonadIO m) => ClSF (EventChanT event m) cl event () emitS = arrMCl emit  -- | Emit an event whenever the input value is @Just event@.-emitSMaybe :: MonadIO m => ClSF (EventChanT event m) cl (Maybe event) ()+emitSMaybe :: (MonadIO m) => ClSF (EventChanT event m) cl (Maybe event) () emitSMaybe = mapMaybe emitS >>> arr (const ())  -- | Like 'emit', but completely evaluates the event before emitting it.@@ -147,7 +147,7 @@ instance Semigroup (EventClock event) where   (<>) _ _ = EventClock -instance MonadIO m => Clock (EventChanT event m) (EventClock event) where+instance (MonadIO m) => Clock (EventChanT event m) (EventClock event) where   type Time (EventClock event) = UTCTime   type Tag (EventClock event) = event   initClock _ = do@@ -168,7 +168,7 @@    to the main loop (see 'withChanS'). -} eventClockOn ::-  MonadIO m =>+  (MonadIO m) =>   Chan event ->   HoistClock (EventChanT event m) m (EventClock event) eventClockOn chan =
src/FRP/Rhine/Clock/Realtime/Millisecond.hs view
@@ -64,7 +64,7 @@    that '-threaded' not be used in order to miss less ticks. The clock will adjust    the wait time, up to no wait time at all, to catch up when a tick is missed. -}-waitClock :: KnownNat n => Millisecond n+waitClock :: (KnownNat n) => Millisecond n waitClock = Millisecond $ RescaledClockS (unyieldClock FixedStep) $ \_ -> do   initTime <- liftIO getCurrentTime   let
src/FRP/Rhine/Clock/Realtime/Stdin.hs view
@@ -25,7 +25,7 @@ -} data StdinClock = StdinClock -instance MonadIO m => Clock m StdinClock where+instance (MonadIO m) => Clock m StdinClock where   type Time StdinClock = UTCTime   type Tag StdinClock = String 
src/FRP/Rhine/Clock/Select.hs view
@@ -69,5 +69,5 @@ {- | Helper function that runs an 'MSF' with 'Maybe' output    until it returns a value. -}-filterS :: Monad m => MSF m () (Maybe b) -> MSF m () b+filterS :: (Monad m) => MSF m () (Maybe b) -> MSF m () b filterS = concatS . (>>> arr maybeToList)
src/FRP/Rhine/ResamplingBuffer/Collect.hs view
@@ -17,7 +17,7 @@ {- | Collects all input in a list, with the newest element at the head,    which is returned and emptied upon `get`. -}-collect :: Monad m => ResamplingBuffer m cl1 cl2 a [a]+collect :: (Monad m) => ResamplingBuffer m cl1 cl2 a [a] collect = timelessResamplingBuffer AsyncMealy {..} []   where     amPut as a = return $ a : as@@ -26,7 +26,7 @@ {- | Reimplementation of 'collect' with sequences,    which gives a performance benefit if the sequence needs to be reversed or searched. -}-collectSequence :: Monad m => ResamplingBuffer m cl1 cl2 a (Seq a)+collectSequence :: (Monad m) => ResamplingBuffer m cl1 cl2 a (Seq a) collectSequence = timelessResamplingBuffer AsyncMealy {..} empty   where     amPut as a = return $ a <| as@@ -37,7 +37,7 @@    Semantically, @pureBuffer f == collect >>-^ arr f@,    but 'pureBuffer' is slightly more efficient. -}-pureBuffer :: Monad m => ([a] -> b) -> ResamplingBuffer m cl1 cl2 a b+pureBuffer :: (Monad m) => ([a] -> b) -> ResamplingBuffer m cl1 cl2 a b pureBuffer f = timelessResamplingBuffer AsyncMealy {..} []   where     amPut as a = return (a : as)@@ -49,7 +49,7 @@    It is strict, i.e. the state value 'b' is calculated on every 'put'. -} foldBuffer ::-  Monad m =>+  (Monad m) =>   -- | The folding function   (a -> b -> b) ->   -- | The initial value
src/FRP/Rhine/ResamplingBuffer/FIFO.hs view
@@ -20,7 +20,7 @@ {- | An unbounded FIFO buffer.    If the buffer is empty, it will return 'Nothing'. -}-fifoUnbounded :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a)+fifoUnbounded :: (Monad m) => ResamplingBuffer m cl1 cl2 a (Maybe a) fifoUnbounded = timelessResamplingBuffer AsyncMealy {..} empty   where     amPut as a = return $ a <| as@@ -31,7 +31,7 @@ {- |  A bounded FIFO buffer that forgets the oldest values when the size is above a given threshold.     If the buffer is empty, it will return 'Nothing'. -}-fifoBounded :: Monad m => Int -> ResamplingBuffer m cl1 cl2 a (Maybe a)+fifoBounded :: (Monad m) => Int -> ResamplingBuffer m cl1 cl2 a (Maybe a) fifoBounded threshold = timelessResamplingBuffer AsyncMealy {..} empty   where     amPut as a = return $ take threshold $ a <| as@@ -40,7 +40,7 @@       as' :> a -> return (Just a, as')  -- | An unbounded FIFO buffer that also returns its current size.-fifoWatch :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a, Int)+fifoWatch :: (Monad m) => ResamplingBuffer m cl1 cl2 a (Maybe a, Int) fifoWatch = timelessResamplingBuffer AsyncMealy {..} empty   where     amPut as a = return $ a <| as
src/FRP/Rhine/ResamplingBuffer/Interpolation.hs view
@@ -26,6 +26,7 @@   , Clock m cl1   , Clock m cl2   , VectorSpace v s+  , Num s   , s ~ Diff (Time cl1)   , s ~ Diff (Time cl2)   ) =>@@ -93,6 +94,7 @@   , VectorSpace v s   , Floating v   , Eq v+  , Fractional s   , s ~ Diff (Time cl1)   , s ~ Diff (Time cl2)   ) =>
src/FRP/Rhine/ResamplingBuffer/KeepLast.hs view
@@ -13,7 +13,7 @@    If @cl2@ approximates continuity,    this behaves like a zero-order hold. -}-keepLast :: Monad m => a -> ResamplingBuffer m cl1 cl2 a a+keepLast :: (Monad m) => a -> ResamplingBuffer m cl1 cl2 a a keepLast = timelessResamplingBuffer AsyncMealy {..}   where     amGet a = return (a, a)
src/FRP/Rhine/ResamplingBuffer/LIFO.hs view
@@ -20,7 +20,7 @@ {- | An unbounded LIFO buffer.    If the buffer is empty, it will return 'Nothing'. -}-lifoUnbounded :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a)+lifoUnbounded :: (Monad m) => ResamplingBuffer m cl1 cl2 a (Maybe a) lifoUnbounded = timelessResamplingBuffer AsyncMealy {..} empty   where     amPut as a = return $ a <| as@@ -31,7 +31,7 @@ {- |  A bounded LIFO buffer that forgets the oldest values when the size is above a given threshold.    If the buffer is empty, it will return 'Nothing'. -}-lifoBounded :: Monad m => Int -> ResamplingBuffer m cl1 cl2 a (Maybe a)+lifoBounded :: (Monad m) => Int -> ResamplingBuffer m cl1 cl2 a (Maybe a) lifoBounded threshold = timelessResamplingBuffer AsyncMealy {..} empty   where     amPut as a = return $ take threshold $ a <| as@@ -40,7 +40,7 @@       a :< as' -> return (Just a, as')  -- | An unbounded LIFO buffer that also returns its current size.-lifoWatch :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a, Int)+lifoWatch :: (Monad m) => ResamplingBuffer m cl1 cl2 a (Maybe a, Int) lifoWatch = timelessResamplingBuffer AsyncMealy {..} empty   where     amPut as a = return $ a <| as
src/FRP/Rhine/ResamplingBuffer/MSF.hs view
@@ -17,7 +17,7 @@    that collects all input in a timestamped list. -} msfBuffer ::-  Monad m =>+  (Monad m) =>   -- | The monadic stream function that consumes   --   a single time stamp for the moment when an output value is required,   --   and a list of timestamped inputs,@@ -28,7 +28,7 @@ msfBuffer = msfBuffer' []   where     msfBuffer' ::-      Monad m =>+      (Monad m) =>       [(TimeInfo cl1, a)] ->       MSF m (TimeInfo cl2, [(TimeInfo cl1, a)]) b ->       ResamplingBuffer m cl1 cl2 a b
src/FRP/Rhine/ResamplingBuffer/Timeless.hs view
@@ -29,7 +29,7 @@    discarding the time stamp. Analogously for 'put'. -} timelessResamplingBuffer ::-  Monad m =>+  (Monad m) =>   AsyncMealy m s a b -> -- The asynchronous Mealy machine from which the buffer is built    -- | The initial state@@ -47,7 +47,7 @@         ResamplingBuffer {..}  -- | A resampling buffer that only accepts and emits units.-trivialResamplingBuffer :: Monad m => ResamplingBuffer m cl1 cl2 () ()+trivialResamplingBuffer :: (Monad m) => ResamplingBuffer m cl1 cl2 () () trivialResamplingBuffer =   timelessResamplingBuffer     AsyncMealy
src/FRP/Rhine/Schedule.hs view
@@ -89,7 +89,7 @@ {- | Two clocks can be combined with a schedule as a clock    for an asynchronous sequential composition of signal networks. -}-data SequentialClock cl1 cl2 = Time cl1 ~ Time cl2 =>+data SequentialClock cl1 cl2 = (Time cl1 ~ Time cl2) =>   SequentialClock   { sequentialCl1 :: cl1   , sequentialCl2 :: cl2@@ -112,7 +112,7 @@ {- | Two clocks can be combined with a schedule as a clock    for an asynchronous parallel composition of signal networks. -}-data ParallelClock cl1 cl2 = Time cl1 ~ Time cl2 =>+data ParallelClock cl1 cl2 = (Time cl1 ~ Time cl2) =>   ParallelClock   { parallelCl1 :: cl1   , parallelCl2 :: cl2
src/FRP/Rhine/Type.hs view
@@ -38,7 +38,7 @@   , clock :: cl   } -instance GetClockProxy cl => ToClockProxy (Rhine m cl a b) where+instance (GetClockProxy cl) => ToClockProxy (Rhine m cl a b) where   type Cl (Rhine m cl a b) = cl  {- |
test/Clock/Millisecond.hs view
@@ -10,7 +10,7 @@ import FRP.Rhine import Util (runRhine) -secondsSinceInit :: Monad m => ClSF m (Millisecond n) a Int+secondsSinceInit :: (Monad m) => ClSF m (Millisecond n) a Int secondsSinceInit = sinceInitS >>> arr round  tests =