elerea 0.5.0 → 0.6.0
raw patch · 5 files changed
+30/−27 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- FRP.Elerea: restarter :: (Void -> Signal a) -> Signal (Signal a)
- FRP.Elerea.Internal: SNR :: (Void -> a) -> SignalNode a
- FRP.Elerea.Internal: data Void
- FRP.Elerea.Internal: restarter :: (Void -> Signal a) -> Signal (Signal a)
+ FRP.Elerea: data StartToken
+ FRP.Elerea: startTokens :: Signal StartToken
+ FRP.Elerea.Internal: SNU :: SignalNode a
+ FRP.Elerea.Internal: data StartToken
+ FRP.Elerea.Internal: startTokens :: Signal StartToken
- FRP.Elerea: (==>) :: Void -> a -> a
+ FRP.Elerea: (==>) :: StartToken -> a -> a
- FRP.Elerea.Internal: (==>) :: Void -> a -> a
+ FRP.Elerea.Internal: (==>) :: StartToken -> a -> a
Files
- CHANGES +4/−0
- FRP/Elerea.hs +4/−3
- FRP/Elerea/Graph.hs +4/−4
- FRP/Elerea/Internal.hs +17/−19
- elerea.cabal +1/−1
CHANGES view
@@ -1,3 +1,7 @@+0.6.0 - 090507+* renamed Void to StartToken+* replaced restarter with the simpler and more versatile startTokens+ 0.5.0 - 090502 * changed names of internal constructors to match primitives better * added restarter and (==>)
FRP/Elerea.hs view
@@ -30,10 +30,11 @@ -} module FRP.Elerea (- DTime, Sink, Signal,+ DTime, Sink, Signal, StartToken, superstep, external, keepAlive, (.@.),- stateful, transfer, latcher, restarter,- delay, edge, (==>),+ stateful, transfer, latcher,+ delay, startTokens, (==>),+ edge, (==@), (/=@), (<@), (<=@), (>=@), (>@), (&&@), (||@) ) where
FRP/Elerea/Graph.hs view
@@ -29,7 +29,7 @@ | Latcher Id Id Id | External | Delay Id- | Restarter+ | Tokens | Lift1 Id | Lift2 Id Id | Lift3 Id Id Id@@ -68,7 +68,7 @@ insertSignal st p (SND _ s) = do (s',st') <- buildStore (Map.insert p None st) s return (Map.insert p (Delay s') st')-insertSignal st p (SNR _) = return (Map.insert p Restarter st)+insertSignal st p (SNU) = return (Map.insert p Tokens st) insertSignal st p (SNKA (S r) _) = do Ready s <- readIORef r insertSignal st p s@@ -106,7 +106,7 @@ App _ _ -> "app" Latcher _ _ _ -> "latcher" External -> "external"- Restarter -> "restarter"+ Tokens -> "tokens" Delay _ -> "delay" Lift1 _ -> "fun1" Lift2 _ _ -> "fun2"@@ -163,6 +163,6 @@ Latcher _ _ _ -> "hexagon" External -> "invtriangle" Delay _ -> "box"- Restarter -> "house"+ Tokens -> "house" _ -> "ellipse" return $ "digraph G {\n" ++ concat rules ++ "}\n"
FRP/Elerea/Internal.hs view
@@ -69,10 +69,10 @@ type Sink a = a -> IO () -{-| An unpopulated type to use as a token for injecting data-dependencies in the restarter. -}+{-| An empty type to use as a token for injecting data+dependencies. -} -data Void+data StartToken -- ** The data structures behind signals @@ -118,8 +118,8 @@ | SNE (IORef a) -- | @SND s@: the @s@ signal delayed by one superstep | SND a (Signal a)- -- | @SNR f@: restarter; always reevaluates @f undefined@- | SNR (Void -> a)+ -- | @SNU@: a stream of unique identifiers for each superstep+ | SNU -- | @SNKA s l@: equivalent to @s@ while aging signal @l@ | forall t . SNKA (Signal a) (Signal t) -- | @SNF1 f@: @fmap f@@@ -377,7 +377,7 @@ signalValue (if b then s' else s) dt sample (SNE r) _ = readIORef r sample (SND v _) _ = return v-sample (SNR f) _ = return (f undefined)+sample (SNU) _ = return undefined sample (SNKA s l) dt = do signalValue l dt signalValue s dt sample (SNF1 f s) dt = f <$> signalValue s dt@@ -466,7 +466,7 @@ {-| Dependency injection to allow aging signals whose output is not necessarily needed to produce the current sample of the first-argument. It equivalent to @(flip . liftA2 . flip) const@, as it+argument. It's equivalent to @(flip . liftA2 . flip) const@, as it evaluates its second argument first. -} keepAlive :: Signal a -- ^ the actual output@@ -474,23 +474,21 @@ -> Signal a keepAlive s l = createSignal (SNKA s l) -{-| Dependency injection to allow signals to be partly restarted,-notably the parts synthesised by the function passed to 'restarter'.-The function receives a dummy value that must not be evaluated (it is-'undefined'), but the result should depend on it somehow to prevent-let-floating from memoising the result outside the function. Such a-dependency can be established with the '==>' operator. Effectively,-'restarter' is a non-memoising version of 'pure' limited to construct-higher-order signals. -}+{-| A stream of tokens freshly generated in each superstep. These are+dummy values that must not be evaluated (they are in fact+'undefined'), but distributed among signals that need to be+constructed at the given moment in the absence of other dependencies+on current values, so as to prevent let-floating from moving otherwise+independent signals to an outer scope. Dependency on these tokens can+be established with the '==>' operator. -} -restarter :: (Void -> Signal a) -- ^ the function to synthesise signal- -> Signal (Signal a)-restarter f = createSignal (SNR f)+startTokens :: Signal StartToken+startTokens = createSignal SNU {-| An operator that ignores its first argument and returns the second, but hides the fact that the first argument is not needed. It is equivalent to @flip const@, but it cannot be inlined. -} {-# NOINLINE (==>) #-}-(==>) :: Void -> a -> a+(==>) :: StartToken -> a -> a _ ==> x = x
elerea.cabal view
@@ -1,5 +1,5 @@ Name: elerea-Version: 0.5.0+Version: 0.6.0 Cabal-Version: >= 1.2 Synopsis: A minimalistic FRP library Category: reactivity, FRP