Yampa 0.13.5 → 0.13.6
raw patch · 12 files changed
+45/−39 lines, 12 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG +9/−0
- Yampa.cabal +1/−1
- src/FRP/Yampa/Delays.hs +2/−2
- src/FRP/Yampa/Diagnostics.hs +1/−1
- src/FRP/Yampa/Event.hs +6/−9
- src/FRP/Yampa/EventS.hs +8/−8
- src/FRP/Yampa/InternalCore.hs +4/−4
- src/FRP/Yampa/Random.hs +3/−3
- src/FRP/Yampa/Simulation.hs +4/−4
- src/FRP/Yampa/Switches.hs +1/−1
- src/FRP/Yampa/Task.hs +3/−3
- src/FRP/Yampa/Time.hs +3/−3
CHANGELOG view
@@ -1,3 +1,12 @@+2022-08-07 Ivan Perez <ivan.perez@haskell.sexy>+ * Yampa.cabal: Version bump (0.13.6) (#232).+ * src/: Fix typos in documentation (#224), replace AFRP with Yampa+ (#223), simplify implementation of mapFilterE (#221).+ * README: Re-structure README, add content, TOC (#227), fix typo+ (#230).+ * Replace funding link (#231).+ * Thanks to @architsinghal-mriirs.+ 2022-06-07 Ivan Perez <ivan.perez@haskell.sexy> * Yampa.cabal: Version bump (0.13.5) (#220). * src/: Remove vim modeline settings (#209), remove unnecessary
Yampa.cabal view
@@ -30,7 +30,7 @@ build-type: Simple name: Yampa-version: 0.13.5+version: 0.13.6 author: Henrik Nilsson, Antony Courtney maintainer: Ivan Perez (ivan.perez@keera.co.uk) homepage: https://github.com/ivanperez-keera/Yampa/
src/FRP/Yampa/Delays.hs view
@@ -40,7 +40,7 @@ pre = sscanPrim f uninit uninit where f c a = Just (a, c)- uninit = usrErr "AFRP" "pre" "Uninitialized pre operator."+ uninit = usrErr "Yampa" "pre" "Uninitialized pre operator." -- | Initialized delay operator. --@@ -66,7 +66,7 @@ -- | Delay a signal by a fixed time 't', using the second parameter -- to fill in the initial 't' seconds. delay :: Time -> a -> SF a a-delay q a_init | q < 0 = usrErr "AFRP" "delay" "Negative delay."+delay q a_init | q < 0 = usrErr "Yampa" "delay" "Negative delay." | q == 0 = identity | otherwise = SF {sfTF = tf0} where
src/FRP/Yampa/Diagnostics.hs view
@@ -7,7 +7,7 @@ -- Stability : provisional -- Portability : portable ----- Standarized error-reporting for Yampa+-- Standardized error-reporting for Yampa module FRP.Yampa.Diagnostics where -- | Reports an error due to a violation of Yampa's preconditions/requirements.
src/FRP/Yampa/Event.hs view
@@ -124,7 +124,7 @@ -- * Internal utilities for event construction --- These utilities are to be considered strictly internal to AFRP for the+-- These utilities are to be considered strictly internal to Yampa for the -- time being. -- | Convert a maybe value into a event ('Event' is isomorphic to 'Maybe').@@ -142,7 +142,7 @@ -- | Extract the value from an event. Fails if there is no event. fromEvent :: Event a -> a fromEvent (Event a) = a-fromEvent NoEvent = usrErr "AFRP" "fromEvent" "Not an event."+fromEvent NoEvent = usrErr "Yampa" "fromEvent" "Not an event." -- | Tests whether the input represents an actual event. isEvent :: Event a -> Bool@@ -186,7 +186,7 @@ -- | Unbiased event merge: simultaneous occurrence is an error. merge :: Event a -> Event a -> Event a-merge = mergeBy (usrErr "AFRP" "merge" "Simultaneous event occurrence.")+merge = mergeBy (usrErr "Yampa" "merge" "Simultaneous event occurrence.") -- | Event merge parameterized by a conflict resolution function. --@@ -224,7 +224,7 @@ -- -- Traverable-based definition: -- catEvents :: Foldable t => t (Event a) -> Event (t a)--- carEvents e = if (null e) then NoEvent else (sequenceA e)+-- catEvents e = if (null e) then NoEvent else (sequenceA e) catEvents :: [Event a] -> Event [a] catEvents eas = case [ a | Event a <- eas ] of [] -> NoEvent@@ -255,12 +255,9 @@ -- | Combined event mapping and filtering. Note: since 'Event' is a 'Functor', -- see 'fmap' for a simpler version of this function with no filtering. mapFilterE :: (a -> Maybe b) -> Event a -> Event b-mapFilterE _ NoEvent = NoEvent-mapFilterE f (Event a) = case f a of- Nothing -> NoEvent- Just b -> Event b+mapFilterE f e = e >>= (maybeToEvent . f) --- | Enable/disable event occurences based on an external condition.+-- | Enable/disable event occurrences based on an external condition. gate :: Event a -> Bool -> Event a _ `gate` False = NoEvent e `gate` True = e
src/FRP/Yampa/EventS.hs view
@@ -94,7 +94,7 @@ -- point in time. repeatedly :: Time -> b -> SF a (Event b) repeatedly q x | q > 0 = afterEach qxs- | otherwise = usrErr "AFRP" "repeatedly" "Non-positive period."+ | otherwise = usrErr "Yampa" "repeatedly" "Non-positive period." where qxs = (q,x):qxs @@ -110,7 +110,7 @@ afterEachCat :: [(Time,b)] -> SF a (Event [b]) afterEachCat [] = never afterEachCat ((q,x):qxs)- | q < 0 = usrErr "AFRP" "afterEachCat" "Negative period."+ | q < 0 = usrErr "Yampa" "afterEachCat" "Negative period." | otherwise = SF {sfTF = tf0} where tf0 _ = if q <= 0@@ -119,7 +119,7 @@ emitEventsScheduleNext _ xs [] = (sfNever, Event (reverse xs)) emitEventsScheduleNext t xs ((q,x):qxs)- | q < 0 = usrErr "AFRP" "afterEachCat" "Negative period."+ | q < 0 = usrErr "Yampa" "afterEachCat" "Negative period." | t' >= 0 = emitEventsScheduleNext t' (x:xs) qxs | otherwise = (awaitNextEvent t' x qxs, Event (reverse xs)) where@@ -133,14 +133,14 @@ -- | Delay for events. (Consider it a triggered after, hence /basic/.) delayEvent :: Time -> SF (Event a) (Event a)-delayEvent q | q < 0 = usrErr "AFRP" "delayEvent" "Negative delay."+delayEvent q | q < 0 = usrErr "Yampa" "delayEvent" "Negative delay." | q == 0 = identity | otherwise = delayEventCat q >>> arr (fmap head) -- | Delay an event by a given delta and catenate events that occur so closely -- so as to be /inseparable/. delayEventCat :: Time -> SF (Event a) (Event [a])-delayEventCat q | q < 0 = usrErr "AFRP" "delayEventCat" "Negative delay."+delayEventCat q | q < 0 = usrErr "Yampa" "delayEventCat" "Negative delay." | q == 0 = arr (fmap (:[])) | otherwise = SF {sfTF = tf0} where@@ -215,14 +215,14 @@ (x' : rxs) -- | A rising edge detector. Useful for things like detecting key presses.--- It is initialised as /up/, meaning that events occuring at time 0 will+-- It is initialised as /up/, meaning that events occurring at time 0 will -- not be detected. edge :: SF Bool (Event ()) edge = iEdge True -- | A rising edge detector that can be initialized as up ('True', meaning -- that events occurring at time 0 will not be detected) or down--- ('False', meaning that events ocurring at time 0 will be detected).+-- ('False', meaning that events occurring at time 0 will be detected). iEdge :: Bool -> SF Bool (Event ()) iEdge b = sscanPrim f (if b then 2 else 0) NoEvent where@@ -239,7 +239,7 @@ edgeTag :: a -> SF Bool (Event a) edgeTag a = edge >>> arr (`tag` a) --- | Edge detector particularized for detecting transtitions+-- | Edge detector particularized for detecting transitions -- on a 'Maybe' signal from 'Nothing' to 'Just'. edgeJust :: SF (Maybe a) (Event a) edgeJust = edgeBy isJustEdge (Just undefined)
src/FRP/Yampa/InternalCore.hs view
@@ -286,7 +286,7 @@ vfyNoEv NoEvent b = b vfyNoEv _ _ = usrErr- "AFRP"+ "Yampa" "vfyNoEv" "Assertion failed: Functions on events must not map NoEvent to Event." @@ -461,7 +461,7 @@ -- the last event-processing function in the chain, it has to be -- remembered. Since the composite event-processing function remains -- constant/unchanged, the NoEvent output has to be part of the state.- -- An alternarive would be to make the event-processing function take+ -- An alternative would be to make the event-processing function take -- an extra argument. But that is likely to make the simple case more -- expensive. See note at sfEP. f (s1, s2, cne) a =@@ -469,7 +469,7 @@ (s1', NoEvent, NoEvent) -> ((s1', s2, cne), cne, cne) (s1', Event b, NoEvent) -> let (s2', c, cne') = f2 s2 b in ((s1', s2', cne'), c, cne')- _ -> usrErr "AFRP" "cpXX" $+ _ -> usrErr "Yampa" "cpXX" $ "Assertion failed: Functions on events must not map " ++ "NoEvent to Event." cpXX sf1@(SFEP{}) (SFCpAXA _ (FDE f21 f21ne) sf22 fd23) =@@ -660,7 +660,7 @@ case f1 s a of (s', NoEvent, NoEvent) -> (s', f2ne, f2ne) (s', eb, NoEvent) -> (s', f2 eb, f2ne)- _ -> usrErr "AFRP" "cpXEAux" $+ _ -> usrErr "Yampa" "cpXEAux" $ "Assertion failed: Functions on events must not " ++ "map NoEvent to Event." cpXEAux fd2 _ _ (SFCpAXA _ fd11 sf12 fd13) =
src/FRP/Yampa/Random.hs view
@@ -41,12 +41,12 @@ noiseR range g0 = streamToSF (randomRs range g0) streamToSF :: [b] -> SF a b-streamToSF [] = intErr "AFRP" "streamToSF" "Empty list!"+streamToSF [] = intErr "Yampa" "streamToSF" "Empty list!" streamToSF (b:bs) = SF {sfTF = tf0} where tf0 _ = (stsfAux bs, b) - stsfAux [] = intErr "AFRP" "streamToSF" "Empty list!"+ stsfAux [] = intErr "Yampa" "streamToSF" "Empty list!" -- Invarying since stsfAux [] is an error. stsfAux (b:bs) = SF' tf -- True where@@ -60,7 +60,7 @@ occasionally :: RandomGen g => g -> Time -> b -> SF a (Event b) occasionally g t_avg x | t_avg > 0 = SF {sfTF = tf0}- | otherwise = usrErr "AFRP" "occasionally"+ | otherwise = usrErr "Yampa" "occasionally" "Non-positive average interval." where -- Generally, if events occur with an average frequency of f, the
src/FRP/Yampa/Simulation.hs view
@@ -185,11 +185,11 @@ tf0 _ = (esAux 0 (zip tts bbs), b) - esAux _ [] = intErr "AFRP" "embedSynch" "Empty list!"+ esAux _ [] = intErr "Yampa" "embedSynch" "Empty list!" -- Invarying below since esAux [] is an error. esAux tp_prev tbtbs = SF' tf -- True where- tf dt r | r < 0 = usrErr "AFRP" "embedSynch" "Negative ratio."+ tf dt r | r < 0 = usrErr "Yampa" "embedSynch" "Negative ratio." | otherwise = let tp = tp_prev + dt * r (b, tbtbs') = advance tp tbtbs in (esAux tp tbtbs', b)@@ -208,12 +208,12 @@ -- unnecessary samples when the input has not changed since -- the last sample. deltaEncode :: Eq a => DTime -> [a] -> (a, [(DTime, Maybe a)])-deltaEncode _ [] = usrErr "AFRP" "deltaEncode" "Empty input list."+deltaEncode _ [] = usrErr "Yampa" "deltaEncode" "Empty input list." deltaEncode dt aas@(_:_) = deltaEncodeBy (==) dt aas -- | 'deltaEncode' parameterized by the equality test. deltaEncodeBy :: (a -> a -> Bool) -> DTime -> [a] -> (a, [(DTime, Maybe a)])-deltaEncodeBy _ _ [] = usrErr "AFRP" "deltaEncodeBy" "Empty input list."+deltaEncodeBy _ _ [] = usrErr "Yampa" "deltaEncodeBy" "Empty input list." deltaEncodeBy eq dt (a0:as) = (a0, zip (repeat dt) (debAux a0 as)) where debAux _ [] = []
src/FRP/Yampa/Switches.hs view
@@ -30,7 +30,7 @@ -- that originally provoked the switch, you are very likely to fall into an -- infinite loop. In those cases, the use of 'dSwitch' or '-->' may help. ----- Switches vary depending on a number of criterions:+-- Switches vary depending on a number of criteria: -- -- - /Decoupled/ vs normal switching /(d)/: when an SF is being applied and a -- different SF needs to be applied next, one question is which one is used
src/FRP/Yampa/Task.hs view
@@ -74,14 +74,14 @@ -- Convenience function for tasks which are known not to terminate. runTask_ :: Task a b c -> SF a b runTask_ tk = runTask tk- >>> arr (either id (usrErr "AFRPTask" "runTask_"+ >>> arr (either id (usrErr "YampaTask" "runTask_" "Task terminated!")) -- | Creates an SF that represents an SF and produces an event -- when the task terminates, and otherwise produces just an output. taskToSF :: Task a b c -> SF a (b, Event c) taskToSF tk = runTask tk- >>> (arr (either id (usrErr "AFRPTask" "runTask_"+ >>> (arr (either id (usrErr "YampaTask" "runTask_" "Task terminated!")) &&& edgeBy isEdge (Left undefined)) where@@ -152,7 +152,7 @@ -- @snapT >> snapT = snapT@ snapT :: Task a b a-snapT = mkTask (constant (intErr "AFRPTask" "snapT" "Bad switch?") &&& snap)+snapT = mkTask (constant (intErr "YampaTask" "snapT" "Bad switch?") &&& snap) -- * Basic tasks combinators
src/FRP/Yampa/Time.hs view
@@ -16,9 +16,9 @@ -- will count using the time of switching as the start time. -- -- Take also into account that, because 'FRP.Yampa.Integration.derivative' is--- the derivative of a signal /over time/, derivating 'localTime' will always--- produce the value one (@1@). If you really, really, really need to know the--- time delta, and need to abandon the hybrid\/FRP abstraction, see+-- the derivative of a signal /over time/, differentiating 'localTime' will+-- always produce the value one (@1@). If you really, really, really need to+-- know the time delta, and need to abandon the hybrid\/FRP abstraction, see -- 'FRP.Yampa.Integration.iterFrom'. module FRP.Yampa.Time ( localTime