reactive-banana 0.2.0.2 → 0.2.0.3
raw patch · 4 files changed
+17/−10 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- doc/examples/SlotMachine.hs +2/−0
- reactive-banana.cabal +1/−1
- src/Reactive/Banana/Implementation.hs +3/−0
- src/Reactive/Banana/PushIO.hs +11/−9
doc/examples/SlotMachine.hs view
@@ -8,6 +8,7 @@ import Control.Monad (when) import Data.Maybe (isJust, fromJust) import System.Random+import System.IO import Debug.Trace import Data.IORef @@ -41,6 +42,7 @@ where loop = do putStr "> "+ hFlush stdout s <- getLine case s of "coin" -> fire escoin () -- fire corresponding events
reactive-banana.cabal view
@@ -1,5 +1,5 @@ Name: reactive-banana-Version: 0.2.0.2+Version: 0.2.0.3 Synopsis: Small but solid library for functional reactive programming (FRP). Description:
src/Reactive/Banana/Implementation.hs view
@@ -27,6 +27,8 @@ import Control.Monad.RWS import Data.IORef +-- debug = putStrLn+ {----------------------------------------------------------------------------- PushIO specific functions ------------------------------------------------------------------------------}@@ -135,6 +137,7 @@ let -- union of all reactimates network = mconcat outputs :: Model.Event PushIO (IO ())+ -- compile network paths <- compileHandlers network -- register event handlers
src/Reactive/Banana/PushIO.hs view
@@ -39,13 +39,13 @@ runStore :: Store a -> IO a runStore = id --- create a new reference. Dummy argument to prevent let floating-newRef :: b -> Ref a+-- create a new reference.+newRef :: Store (Ref a) -- read a reference. Only possible in the Store monad. readRef :: Ref a -> Store (Maybe a) writeRef :: Ref a -> a -> Store () -newRef b = unsafePerformIO . seq [b] . newIORef $ Nothing+newRef = newIORef Nothing readRef = readIORef writeRef ref = writeIORef ref . Just @@ -332,16 +332,18 @@ -- sharing behavior :: BehaviorD Accum a -> Model.Behavior PushIO a-behavior b = Behavior (ref, b)+behavior b = Behavior pair where- {-# NOINLINE ref #-} - ref = newRef b+ {-# NOINLINE pair #-}+ -- mention argument to prevent let-floating + pair = unsafePerformIO (fmap (,b) newRef) event :: EventD Accum a -> Model.Event PushIO a-event e = Event (ref, e)+event e = Event pair where- {-# NOINLINE ref #-}- ref = newRef e+ {-# NOINLINE pair #-}+ -- mention argument to prevent let-floating+ pair = unsafePerformIO (fmap (,e) newRef) -- boilerplate class instances instance Functor (Model.Event PushIO) where