timers-tick 0.1.2.0 → 0.2.0.0
raw patch · 4 files changed
+25/−7 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Control.Timer.Tick: fetch :: TimedRes a -> a
+ Control.Timer.Tick: fetchFrame :: TimedRes a -> a
+ Control.Timer.Tick: getFrames :: TimedRes a -> [(Integer, a)]
+ Control.Timer.Tick: instance GHC.Base.Functor Control.Timer.Tick.TimedRes
Files
- changes.txt +8/−0
- src/Control/Timer/Tick.hs +14/−4
- test/Control/Timer/TickSpec.hs +2/−2
- timers-tick.cabal +1/−1
changes.txt view
@@ -1,3 +1,11 @@+0.2.0.0+-------++- Renamed `fetch` to `fetchFrame`.+- Added `getFrames`.+- Added Functor instance+- Released Thu 15 Mar 2018 03:33:20 CET+ 0.1.2.0 -------
src/Control/Timer/Tick.hs view
@@ -29,12 +29,13 @@ -- * Query isLive, isExpired,- fetch+ fetchFrame,+ getFrames ) where-+ import GHC.Generics (Generic) -----------@@ -80,6 +81,11 @@ -- todo Monoid (or semigroup) <> for timers [2.0] +-- | For easy mapping on frames.+instance Functor TimedRes where+ fmap f t = t { tSteps = fmap (\(i, a) -> (i, f a))+ (tSteps t) }+ ------------ -- CREATE -- ------------@@ -153,10 +159,14 @@ isExpired t = tExpired t -- | Fetches the current resource of the timer.-fetch :: TimedRes a -> a-fetch t = bl !! (fromIntegral $ tCurrTick t)+fetchFrame :: TimedRes a -> a+fetchFrame t = bl !! (fromIntegral $ tCurrTick t) where bl = concatMap (\(c, a) -> replicate (fromIntegral c) a) $ tSteps t++-- | Return a list of all frames plus the display timelenght.+getFrames :: TimedRes a -> [(Integer, a)]+getFrames t = tSteps t -- todo having another input apart from []? maybe a function?
test/Control/Timer/TickSpec.hs view
@@ -50,10 +50,10 @@ it "complements isLive" $ isExpired (ticks 100 st) `shouldBe` not (isLive (ticks 100 st)) - describe "fetch" $ do+ describe "fetchFrame" $ do let ta = creaTimedRes (Times 1) [(1,'a'), (2, 'b'), (1, 'c')] it "gets the underlying resoure" $- fetch (ticks 3 ta) `shouldBe` 'c'+ fetchFrame (ticks 3 ta) `shouldBe` 'c' describe "reset" $ do let t = creaTimer 10
timers-tick.cabal view
@@ -1,5 +1,5 @@ name: timers-tick-version: 0.1.2.0+version: 0.2.0.0 synopsis: tick based timers description: Tick-based timers and utilities, for games and discrete-time programs.