reactive 0.2 → 0.3
raw patch · 5 files changed
+46/−16 lines, 5 files
Files
- changes.tw +20/−0
- reactive.cabal +1/−1
- src/Data/Future.hs +3/−1
- src/Data/Reactive.hs +18/−13
- src/Data/SFuture.hs +4/−1
+ changes.tw view
@@ -0,0 +1,20 @@+== Version 0 ==++=== Version 0.3 ===++* Commented out LANGUAGE pragmas and added OPTIONS_GHC -fglasgow-exts for ghc-6.6 compatibility.++=== Version 0.2 ===++* Fixed <hask>switcher</hask>. Didn't terminate. Thanks to Ivan Tomac for the bug report.++=== Version 0.1 ===++* Added <hask>Never</hask> constructor for Future. Allows optimizations, including a huge improvement for <hask>(>>=)</hask> on <hask>Event</hask> (which had been piling up <hask>never</hask>s).+* removed <code>-threaded</code> comment+* added <hask>traceR</hask> (reactive value tracing)+* use idler in <code>src/Examples.hs</code> (for single-threaded use of wxHaskell)++=== Version 0.0 ===++* New project.
reactive.cabal view
@@ -1,5 +1,5 @@ Name: reactive-Version: 0.2+Version: 0.3 Synopsis: Simple foundation for functional reactive programming Category: reactivity, FRP Description:
src/Data/Future.hs view
@@ -1,4 +1,6 @@-{-# LANGUAGE RecursiveDo #-}+-- {-# LANGUAGE RecursiveDo #-}+-- For ghc-6.6 compatibility+{-# OPTIONS_GHC -fglasgow-exts #-} {-# OPTIONS -fno-warn-orphans #-} ----------------------------------------------------------------------
src/Data/Reactive.hs view
@@ -1,7 +1,11 @@-{-# LANGUAGE TypeOperators, ScopedTypeVariables, PatternSignatures- , FlexibleInstances- #-}+-- {-# LANGUAGE TypeOperators, ScopedTypeVariables, PatternSignatures+-- , FlexibleInstances+-- #-} +-- For ghc-6.6 compatibility+{-# OPTIONS_GHC -fglasgow-exts #-}++ ---------------------------------------------------------------------- -- | -- Module : Data.Reactive@@ -273,16 +277,16 @@ --------------------------------------------------------------------} -- | Accumulating event, starting from an initial value and a--- update-function event.+-- update-function event. See also 'accumR'. accumE :: a -> Event (a -> a) -> Event a accumE a = inEvent $ fmap $ \ (f `Stepper` e') -> f a `accumR` e' --- | Like 'scanl' for events+-- | Like 'scanl' for events. See also 'scanE'. scanlE :: (a -> b -> a) -> a -> Event b -> Event a scanlE f a e = a `accumE` (flip f <$> e) -- | Accumulate values from a monoid-valued event. Specialization of--- 'scanlE', using 'mappend' and 'mempty'+-- 'scanlE', using 'mappend' and 'mempty'. See also 'monoidR'. monoidE :: Monoid o => Event o -> Event o monoidE = scanlE mappend mempty @@ -298,7 +302,7 @@ combineMaybes = uncurry (liftA2 (,)) -- | Count occurrences of an event, remembering the occurrence values.--- See also 'countE_' +-- See also 'countE_'. countE :: Num n => Event b -> Event (b,n) countE = scanlE h (b0,0) where@@ -306,7 +310,7 @@ h (_,n) b = (b,n+1) -- | Count occurrences of an event, forgetting the occurrence values. See--- also 'countE'.+-- also 'countE'. See also 'countR'. countE_ :: Num n => Event b -> Event n countE_ e = snd <$> countE e @@ -356,7 +360,8 @@ -- | Make an extensible event. The returned sink is a way to add new--- events to mix.+-- events to mix. You can often use '(>>=)' or 'join' instead. Warning:+-- this function might be removed at some point. eventX :: IO (Event a, Sink (Event a)) eventX = first join <$> mkEvent @@ -368,16 +373,16 @@ mkReactive :: a -> IO (Reactive a, Sink a) mkReactive a0 = first (a0 `stepper`) <$> mkEvent --- | Reactive value from an initial value and an updater event+-- | Reactive value from an initial value and an updater event. See also 'accumE'. accumR :: a -> Event (a -> a) -> Reactive a a `accumR` e = a `stepper` (a `accumE` e) --- | Like 'scanl' for reactive values+-- | Like 'scanl' for reactive values. See also 'scanE'. scanlR :: (a -> b -> a) -> a -> Event b -> Reactive a scanlR f a e = a `stepper` scanlE f a e -- | Accumulate values from a monoid-valued event. Specialization of--- 'scanlE', using 'mappend' and 'mempty'+-- 'scanlE', using 'mappend' and 'mempty'. See also 'monoidE'. monoidR :: Monoid a => Event a -> Reactive a monoidR = scanlR mappend mempty @@ -397,7 +402,7 @@ -- TODO: generalize 'maybeR' & 'flipFlop'. Perhaps using 'Monoid'. -- Note that Nothing and (Any False) are mempty. --- | Count occurrences of an event+-- | Count occurrences of an event. See also 'countE'. countR :: Num n => Event a -> Reactive n countR e = 0 `stepper` countE_ e
src/Data/SFuture.hs view
@@ -1,5 +1,8 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-}+-- {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# OPTIONS -Wall -fno-warn-orphans #-}+-- For ghc-6.6 compatibility+{-# OPTIONS_GHC -fglasgow-exts #-}+ ---------------------------------------------------------------------- -- | -- Module : Data.SFuture