packages feed

sodium 0.5.0.2 → 0.6

raw patch · 5 files changed

+18/−40 lines, 5 files

Files

examples/tests/unit-tests.hs view
@@ -326,8 +326,8 @@     (ea, push) <- sync newEvent     outRef <- newIORef []     unlisten <- sync $ do-        eCount <- countE ea-        listen eCount $ \c -> modifyIORef outRef (++ [c])+        count <- count ea+        listen (changes count) $ \c -> modifyIORef outRef (++ [c])     sync $ push ()     sync $ push ()     sync $ push ()
sodium.cabal view
@@ -1,5 +1,5 @@ name:                sodium-version:             0.5.0.2+version:             0.6 synopsis:            Sodium Reactive Programming (FRP) System description:            A general purpose Reactive Programming (FRP) system. This is part of a project to@@ -25,7 +25,8 @@            0.4.0.0 API revamp to remove an excess type variable. Parallelism stuff to be rethought;            0.5.0.0 Improved tests cases + add Freecell example, API tweaks;            0.5.0.1 Internal improvements;-           0.5.0.2 Fix multiple memory leaks+           0.5.0.2 Fix multiple memory leaks;+           0.6     Minor API changes, particular with accum. license:             BSD3 license-file:        LICENSE author:              Stephen Blackheath
src/FRP/Sodium.hs view
@@ -23,13 +23,12 @@ -- all 'hold's are delayed, so 'attachWith' will capture the /old/ value of the state /s/. -- -- > {-# LANGUAGE DoRec #-}--- > -- | Accumulate on input event, outputting the new state each time.--- > accumE :: (a -> s -> s) -> s -> Event a -> Reactive (Event s) --- > accumE f z ea = do+-- > -- | Accumulate state changes given in the input event.+-- > accum :: Context r => a -> Event r (a -> a) -> Reactive r (Behavior r a)+-- > accum z efa = do -- >     rec--- >         let es = attachWith f ea s--- >         s <- hold z es--- >     return es+-- >         s <- hold z $ snapshotWith ($) efa s+-- >     return s module FRP.Sodium (         Plain,         -- * Running FRP code@@ -62,9 +61,7 @@         gate,         collectE,         collect,-        accumE,         accum,-        countE,         count,         once     ) where
src/FRP/Sodium/Context.hs view
@@ -149,26 +149,14 @@         let ebs = snapshotWith f ea (snd <$> bs)     return (fst <$> bs) --- | Accumulate on input event, outputting the new state each time.-accumE :: Context r => (a -> s -> s) -> s -> Event r a -> Reactive r (Event r s) -accumE f z ea = do-    rec-        let es = snapshotWith f ea s-        s <- hold z es-    return es---- | Accumulate on input event, holding state.-accum :: Context r => (a -> s -> s) -> s -> Event r a -> Reactive r (Behavior r s)-accum f z ea = do+-- | Accumulate state changes given in the input event.+accum :: Context r => a -> Event r (a -> a) -> Reactive r (Behavior r a)+accum z efa = do     rec-        s <- hold z (snapshotWith f ea s)+        s <- hold z $ snapshotWith ($) efa s     return s --- | Count event occurrences, starting with 1 for the first occurrence.-countE :: Context r => Event r a -> Reactive r (Event r Int)-countE = accumE (+) 0 . (const 1 <$>)- -- | Count event occurrences, giving a behavior that starts with 0 before the first occurrence. count :: Context r => Event r a -> Reactive r (Behavior r Int)-count = hold 0 <=< countE+count = accum 0 . (const (1+) <$>) 
src/FRP/Sodium/Plain.hs view
@@ -244,7 +244,7 @@ changes       :: Behavior a -> Event a changes = underlyingEvent --- | An event that is guaranteed to fires once when you listen to it, giving+-- | An event that is guaranteed to fire once when you listen to it, giving -- the current value of the behavior, and thereafter behaves like 'changes', -- firing for each update to the behavior's value. values        :: Behavior a -> Event a@@ -414,17 +414,9 @@ collect :: (a -> s -> (b, s)) -> s -> Behavior a -> Reactive (Behavior b) collect = R.collect --- | Accumulate on input event, outputting the new state each time.-accumE :: (a -> s -> s) -> s -> Event a -> Reactive (Event s) -accumE = R.accumE---- | Accumulate on input event, holding state.-accum :: (a -> s -> s) -> s -> Event a -> Reactive (Behavior s)+-- | Accumulate state changes given in the input event.+accum :: a -> Event (a -> a) -> Reactive (Behavior a) accum = R.accum---- | Count event occurrences, starting with 1 for the first occurrence.-countE :: Event a -> Reactive (Event Int)-countE = R.countE  -- | Count event occurrences, giving a behavior that starts with 0 before the first occurrence. count :: Event a -> Reactive (Behavior Int)