summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchanges.tw20
-rwxr-xr-xreactive.cabal2
-rwxr-xr-xsrc/Data/Future.hs4
-rwxr-xr-xsrc/Data/Reactive.hs31
-rwxr-xr-xsrc/Data/SFuture.hs5
5 files changed, 46 insertions, 16 deletions
diff --git a/changes.tw b/changes.tw
new file mode 100755
index 0000000..6965df0
--- /dev/null
+++ b/changes.tw
@@ -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.
diff --git a/reactive.cabal b/reactive.cabal
index f231249..f97835a 100755
--- a/reactive.cabal
+++ b/reactive.cabal
@@ -1,5 +1,5 @@
Name: reactive
-Version: 0.2
+Version: 0.3
Synopsis: Simple foundation for functional reactive programming
Category: reactivity, FRP
Description:
diff --git a/src/Data/Future.hs b/src/Data/Future.hs
index 471bba8..66126c2 100755
--- a/src/Data/Future.hs
+++ b/src/Data/Future.hs
@@ -1,4 +1,6 @@
-{-# LANGUAGE RecursiveDo #-}
+-- {-# LANGUAGE RecursiveDo #-}
+-- For ghc-6.6 compatibility
+{-# OPTIONS_GHC -fglasgow-exts #-}
{-# OPTIONS -fno-warn-orphans #-}
----------------------------------------------------------------------
diff --git a/src/Data/Reactive.hs b/src/Data/Reactive.hs
index 50b126a..d47ea30 100755
--- a/src/Data/Reactive.hs
+++ b/src/Data/Reactive.hs
@@ -1,6 +1,10 @@
-{-# LANGUAGE TypeOperators, ScopedTypeVariables, PatternSignatures
- , FlexibleInstances
- #-}
+-- {-# LANGUAGE TypeOperators, ScopedTypeVariables, PatternSignatures
+-- , FlexibleInstances
+-- #-}
+
+-- For ghc-6.6 compatibility
+{-# OPTIONS_GHC -fglasgow-exts #-}
+
----------------------------------------------------------------------
-- |
@@ -273,16 +277,16 @@ forkR (act `Stepper` e) = act >> forkE e
--------------------------------------------------------------------}
-- | 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 @@ withPrevE e = (joinMaybes . fmap combineMaybes) $
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 @@ countE = scanlE h (b0,0)
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 @@ traceE shw = fmap (\ a -> trace (shw a) a)
-- | 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 @@ eventX = first join <$> mkEvent
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 @@ flipFlop ea eb =
-- 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
diff --git a/src/Data/SFuture.hs b/src/Data/SFuture.hs
index 327ad5c..4375a1d 100755
--- a/src/Data/SFuture.hs
+++ b/src/Data/SFuture.hs
@@ -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