packages feed

reactive-banana 0.4.3.0 → 0.4.3.1

raw patch · 2 files changed

+12/−4 lines, 2 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Reactive.Banana.Model: filterJust :: FRP f => Event f (Maybe a) -> Event f a

Files

reactive-banana.cabal view
@@ -1,5 +1,5 @@ Name:                reactive-banana-Version:             0.4.3.0+Version:             0.4.3.1 Synopsis:            Small but solid library for                      functional reactive programming (FRP). Description:         
src/Reactive/Banana/Model.hs view
@@ -14,8 +14,9 @@     FRP(..),     Event, Behavior,     -- $classes+         -- * Derived Combinators-    whenE, mapAccum, Apply(..),+    whenE, filterJust, mapAccum, Apply(..),          -- * Model implementation     Model,@@ -24,6 +25,7 @@  import Control.Applicative import qualified Data.List+import Data.Maybe import Prelude hiding (filter) import Data.Monoid @@ -179,6 +181,11 @@ whenE :: FRP f => Behavior f Bool -> Event f a -> Event f a whenE bf = filterApply (const <$> bf) +-- | Variant of 'filterE'. Keep only the 'Just' values.+filterJust :: FRP f => Event f (Maybe a) -> Event f a+filterJust = fmap (maybe err id) . filterE isJust+    where err = error "Reactive.Banana.Model.filterJust: Internal error. :("+ -- | Efficient combination of 'accumE' and 'accumB'. mapAccum :: FRP f => acc -> Event f (acc -> (x,acc)) -> (Event f x, Behavior f acc) mapAccum acc ef = (fst <$> e, stepper acc (snd <$> e))@@ -239,8 +246,9 @@         accumE' acc []     = []         accumE' acc (e:es) = e' : accumE' acc' es             where-            e'   = tail $ scanl' (flip ($)) acc e-            acc' = last e'+            vals = scanl' (flip ($)) acc e+            e'   = tail $ vals+            acc' = last vals  -- strict version of scanl scanl' :: (a -> b -> a) -> a -> [b] -> [a]