reactive 0.8.3 → 0.8.6
raw patch · 3 files changed
+33/−89 lines, 3 files
Files
- reactive.cabal +9/−3
- src/FRP/Reactive/LegacyAdapters.hs +23/−85
- src/FRP/Reactive/Num.hs +1/−1
reactive.cabal view
@@ -1,5 +1,5 @@ Name: reactive-Version: 0.8.3+Version: 0.8.6 Synopsis: Simple foundation for functional reactive programming Category: reactivity, FRP Description:@@ -9,12 +9,18 @@ demand/data-driven implementation, as described in the paper \"Simply efficient functional reactivity\", <http://conal.net/papers/simply-reactive/>. .+ Import "FRP.Reactive" for FRP client apps. To make an Reactive adapter for an+ imperative library, import "FRP.Reactive.LegacyAdapters".+ . Please see the project wiki page: <http://haskell.org/haskellwiki/reactive> . The module documentation pages have links to colorized source code and to wiki pages where you can read and contribute user comments. Enjoy! . © 2007-2008 by Conal Elliott; BSD3 license.+ .+ Contributions from: Thomas Davie, Luke Palmer, David Sankel. (Please let me+ know if I've forgotten to list you.) Author: Conal Elliott Maintainer: conal@conal.net Homepage: http://haskell.org/haskellwiki/reactive@@ -46,8 +52,6 @@ FRP.Reactive.Num FRP.Reactive.VectorSpace - -- FRP.Reactive.LegacyAdapters- FRP.Reactive.Internal.Misc FRP.Reactive.Internal.Fun FRP.Reactive.Internal.Future@@ -55,6 +59,8 @@ FRP.Reactive.Internal.Behavior FRP.Reactive.Internal.Clock FRP.Reactive.Internal.Timing++ FRP.Reactive.LegacyAdapters Data.AddBounds Data.Min
src/FRP/Reactive/LegacyAdapters.hs view
@@ -1,87 +1,25 @@-{-# LANGUAGE Rank2Types #-}-{-# OPTIONS_GHC -Wall #-}-module FRP.Reactive.LegacyAdapters - ( BehaviorMachine(..)- , makeBehaviorMachine- , makeEvent, Sink- -- * Deprecated and/or for testing.- , forkE- , forkB- ) where--import Control.Compose ((:.)(O))-import Control.Concurrent(ThreadId)--import System.Time--import FRP.Reactive.Improving-import FRP.Reactive.Future-import FRP.Reactive.Fun-import FRP.Reactive.Reactive-import Data.Max-import Data.AddBounds--import qualified FRP.Reactive.Internal.Reactive as R-import FRP.Reactive.Internal.Misc (Sink)-import FRP.Reactive.Behavior (Behavior)-import FRP.Reactive.Internal.Behavior (BehaviorG(..))--import qualified FRP.Reactive.Internal.TVal as TVal-import FRP.Reactive.Internal.Clock---data BehaviorMachine a- = BehaviorMachine { currentValue :: a- , currentTime :: TimeT- , waitChange :: IO (BehaviorMachine a)- }--makeBehaviorMachine :: ClockTime -> Behavior a -> IO (BehaviorMachine a)-makeBehaviorMachine refTime (Beh (O (R.Stepper initval ev))) = do- clock <- makeClock refTime- curTime <- currRelTime refTime- return $ eventBehaviorMachine refTime clock initval curTime ev--eventBehaviorMachine :: ClockTime -> Clock TimeT - -> Fun TimeT a -> TimeT -> Event (Fun TimeT a) -> BehaviorMachine a-eventBehaviorMachine refTime clock = go - where- go initVal initTime event = - BehaviorMachine { currentValue = apply initVal initTime- , currentTime = initTime- , waitChange = do- let fut = eventOcc event- schedule clock (fromTime (futTime fut))- let (v,nexte) = futVal fut- curTime <- currRelTime refTime- return $ go v curTime nexte- }--fromTime :: Num a => Max (AddBounds (Improving a)) -> a-fromTime (Max MinBound) = 0-fromTime (Max (NoBound t)) = exact t-fromTime (Max MaxBound) = error "maxbound"---makeEvent :: ClockTime -> IO (Event a, Sink a)-makeEvent refTime = TVal.makeEvent =<< makeClock refTime+{-# OPTIONS -Wall #-}+----------------------------------------------------------------------+-- |+-- Module : FRP.Reactive.LegacyAdapters+-- Copyright : (c) Conal Elliott 2008+-- License : BSD3+-- +-- Maintainer : conal@conal.net+-- Stability : experimental+-- +-- Tools for making Reactive adapters for imperative (\"legacy\")+-- libraries.+---------------------------------------------------------------------- --- | Forks a behavior given a reference time and a time function sinker. This--- function is deprecated, but will remain until something better, and working,--- comes along.-forkB :: ClockTime -> -- The reference time- Behavior a -> -- The behavior- Sink (Fun TimeT a) -> -- An action that takes in a Fun of time to a- IO ThreadId-forkB refTime (Beh (O r)) fSync = do- clock <- makeClock refTime- R.forkR (schedule clock . exact) (fmap fSync r)+module FRP.Reactive.LegacyAdapters+ ( Sink, Action+ , makeClock, cGetTime+ , makeEvent+ , mkUpdater+ ) where --- | A version of forkE that acts more like makeEvent and uses Clock as a--- basis. Takes reference time and the event to fork.-forkE :: ClockTime ->- Event (IO a) ->- IO ThreadId-forkE refTime e = do- clock <- makeClock refTime- R.forkE (schedule clock . exact) e+import FRP.Reactive.Internal.Misc (Sink,Action)+import FRP.Reactive.Internal.Clock (makeClock,cGetTime)+import FRP.Reactive.Internal.TVal (makeEvent)+import FRP.Reactive.Internal.Timing (mkUpdater)
src/FRP/Reactive/Num.hs view
@@ -10,7 +10,7 @@ noOv ty meth = error $ meth ++ ": No overloading for " ++ ty noFun :: String -> a-noFun = noOv "function"+noFun = noOv "behavior" -- Eq & Show are prerequisites for Num, so they need to be faked here instance Eq (Behavior b) where