varying 0.1.1.0 → 0.1.1.1
raw patch · 2 files changed
+16/−13 lines, 2 files
Files
- src/Control/Varying/Event.hs +14/−11
- varying.cabal +2/−2
src/Control/Varying/Event.hs view
@@ -296,10 +296,6 @@ where check (Event b) = if p b then Event b else NoEvent check _ = NoEvent --- | TODO:--- | Produce events of a stream only when both streams produce events.--- | Combine simultaneous events.- -- | Never produces any event values. never :: Monad m => Var m b (Event c) never = pure NoEvent@@ -352,16 +348,23 @@ NoEvent -> v Event b -> f b --- | Produce event values only when the input value passes the predicate.--- Maintains state when 'cold'.-onlyWhen :: Monad m => Var m a b -> (a -> Bool) -> Var m a (Event b)+-- | Produce events of a varying value 'v' only when its input value passes a+-- predicate 'f'.+-- 'v' maintains state while cold.+onlyWhen :: Monad m+ => Var m a b -- ^ 'v' - The varying value+ -> (a -> Bool) -- ^ 'f' - The predicate to run on 'v''s input values.+ -> Var m a (Event b) onlyWhen v f = v `onlyWhenE` hot where hot = var id ~> onWhen f --- | Produce event values from the first signal only when an event is--- produced by the second signal.--- Maintains state when 'cold'.-onlyWhenE :: Monad m => Var m a b -> Var m a (Event c) -> Var m a (Event b)+-- | Produce events of a varying value 'v' only when an event stream 'h'+-- produces an event.+-- 'v' and 'h' maintain state while cold.+onlyWhenE :: Monad m+ => Var m a b -- ^ 'v' - The varying value+ -> Var m a (Event c) -- ^ 'h' - The event stream+ -> Var m a (Event b) onlyWhenE v hot = Var $ \a -> do (e, hot') <- runVar hot a if isEvent e
varying.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.1.0+version: 0.1.1.1 -- A short (one-line) description of the package. synopsis: Automaton based varying values, event streams and tweening.@@ -40,7 +40,7 @@ -- A copyright notice. -- copyright: -category: Control+category: Control, FRP build-type: Simple