packages feed

frpnow 0.15 → 0.16

raw patch · 5 files changed

+31/−7 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Control.FRPNow.Time: delay :: Eq time => Behavior time -> a -> Behavior a -> Behavior (Behavior a)
+ Control.FRPNow.EvStream: delay :: EvStream x -> a -> Behavior a -> Behavior (Behavior a)
+ Control.FRPNow.Time: delayTime :: Eq time => Behavior time -> a -> Behavior a -> Behavior (Behavior a)

Files

ChangeLog view
@@ -1,3 +1,4 @@+0.16 Added EvStream.delay 0.15 Fixes a Prelude.undefined error 0.14 Fixes a space leak, fixes integration being factor 2 off 0.13 Removed Show from integrate, added cstep
Control/FRPNow/EvStream.hs view
@@ -33,7 +33,7 @@   -- * Filter and scan   catMaybesEs,filterEs,filterMapEs,filterMapEsB, filterB, during, beforeEs,   -- * Combine behavior and eventstream-  (<@@>) , snapshots,+  (<@@>) , snapshots, delay,   -- * IO interface   callbackStream,callStream, callIOStream,   -- * Debug @@ -273,6 +273,24 @@         choose (Right x) = return x              +-- | Delay a behavior by one tick of the ``clock''.+--+-- The event stream functions as the ``clock'': the input behavior is sampled on each +-- event, and the current value of the output behavior is always the previously sample. +--+--  Occasionally useful to prevent immediate feedback loops.+delay ::  EvStream x -- ^ The event stream that functions as the ``clock''+          -> a -- ^ The inital value of the output behavior+          -> Behavior a  -- ^ The input behavior+          -> Behavior (Behavior a)+delay s i b = loop i where+  loop i =+           do e <- futuristic $ +                        do cur <- b+                           e <- getEs s+                           return (cur <$ e)+              e' <- plan ( loop <$> e)+              return (i `step` e')  -- | Create an event stream that has an event each time the -- returned function is called. The function can be called from any thread.
Control/FRPNow/Lib.hs view
@@ -73,6 +73,9 @@   boolToMaybe False  = Nothing  +-- | Gives the previous value of the behavior, starting with given value. +-- +--  This /cannot/ be used to prevent immediate feedback loop! Use 'Control.FRPNow.EvStream.delay' instead! prev :: Eq a => a -> Behavior a -> Behavior (Behavior a) prev i b = loop i where   loop i = do e <- nxtCur@@ -185,6 +188,8 @@ -- value of the given behavior at that time. (<@>) :: Behavior (a -> b) -> Event a -> Behavior (Event b) b <@> e = plan $ fmap (\x -> b <*> pure x) e++   
Control/FRPNow/Time.hs view
@@ -16,7 +16,7 @@ -- The clock itself is created by a function specialized to the -- GUI library you are using FRP with such as 'Control.FRPNow.GTK.getClock' -module Control.FRPNow.Time(localTime,timeFrac, lastInputs, bufferBehavior,delayBy, delayByN, delay, integrate, VectorSpace(..)) where+module Control.FRPNow.Time(localTime,timeFrac, lastInputs, bufferBehavior,delayBy, delayByN, delayTime, integrate, VectorSpace(..)) where  import Control.FRPNow.Core import Control.FRPNow.Lib@@ -128,14 +128,14 @@ integrate :: (VectorSpace v time) =>               Behavior time -> Behavior v -> Behavior (Behavior v) integrate time v = do t <- time -                      vp <- delay time (t,zeroVector) ((,) <$> time <*> v)+                      vp <- delayTime time (t,zeroVector) ((,) <$> time <*> v)                       foldB add zeroVector $ (,) <$> vp <*> time    where add total ((t1,v),t2) = total ^+^ ((t2 - t1) *^ v)  --- | Delay a behavior by one tick of the clock. Occasionally useful to prevent immediate feedback loops.-delay ::  Eq time  =>  Behavior time -> a -> Behavior a -> Behavior (Behavior a)-delay time i b = loop i where+-- | Delay a behavior by one tick of the clock. Occasionally useful to prevent immediate feedback loops. Like 'Control.FRPNow.EvStream.delay', but uses the changes of the clock as an event stream.+delayTime ::  Eq time  =>  Behavior time -> a -> Behavior a -> Behavior (Behavior a)+delayTime time i b = loop i where   loop i =            do e <- futuristic $                          do (t,cur) <- (,) <$> time <*> b
frpnow.cabal view
@@ -1,5 +1,5 @@ Name:                frpnow-Version:             0.15+Version:             0.16 Synopsis:	     Principled practical FRP Description:         FRP with first-class behaviors and interalized IO, without space leaks License:             BSD3