reactive-banana-automation 0.4.0 → 0.5.0
raw patch · 3 files changed
+18/−6 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Reactive.Banana.Automation: onEvent :: Event a -> (a -> IO ()) -> Automation sensors actuators ()
+ Reactive.Banana.Automation: actuateEvent :: Event a -> (a -> actuators) -> Automation sensors actuators ()
Files
- CHANGELOG +8/−0
- Reactive/Banana/Automation.hs +9/−5
- reactive-banana-automation.cabal +1/−1
CHANGELOG view
@@ -1,3 +1,11 @@+reactive-banana-automation (0.5.0) upstream; urgency=medium++ * Remove onEvent, which allowed arbitrary IO not connected with+ actuators, and so was not good for testing. (API change)+ * Add actuateEvent.++ -- Joey Hess <id@joeyh.name> Tue, 22 May 2018 17:25:45 -0400+ reactive-banana-automation (0.4.0) upstream; urgency=medium * Simplified using ReaderT, so sensors and actuators do not need to be
Reactive/Banana/Automation.hs view
@@ -26,7 +26,6 @@ fromEventSource, gotEvent, getEventFrom,- onEvent, -- * Sensors Sensed (..), sensedEvent,@@ -48,6 +47,7 @@ clockSignalBehavior, -- * Actuators PowerChange(..),+ actuateEvent, actuateBehavior, actuateBehaviorMaybe, -- * Ranges@@ -114,9 +114,11 @@ instance Monad (Automation sensors actuators) where return = Automation . return m >>= g = Automation $ unAutomation m >>= unAutomation . g+ instance Applicative (Automation sensors actuators) where pure = Automation . pure f <*> a = Automation $ unAutomation f <*> unAutomation a+ instance MonadFix (Automation sensors actuators) where mfix f = Automation $ mfix (unAutomation . f) @@ -223,10 +225,6 @@ sensor <- getsensor . fst <$> ask lift $ fromAddHandler $ addHandler sensor --- | Runs an action when an event occurs.-onEvent :: Event a -> (a -> IO ()) -> Automation sensors actuators ()-onEvent e a = Automation . lift . reactimate $ fmap a e- -- | A value read from a sensor. -- -- Sensors are sometimes not available, or have not provided a value@@ -378,6 +376,12 @@ -- their power turned on and off. data PowerChange = PowerOff | PowerOn deriving (Show)++-- | Makes an Event drive an actuator.+actuateEvent :: Event a -> (a -> actuators) -> Automation sensors actuators ()+actuateEvent e getactuator = Automation $ do+ actuators <- snd <$> ask+ lift $ reactimate $ fmap (actuators . getactuator) e -- | Makes a Behavior drive an actuator. This will happen when the -- Behavior's value changes, but possibly more often as well, depending on
reactive-banana-automation.cabal view
@@ -1,5 +1,5 @@ Name: reactive-banana-automation-Version: 0.4.0+Version: 0.5.0 Cabal-Version: >= 1.8 License: AGPL-3 Maintainer: Joey Hess <id@joeyh.name>