numerus-closus 0.4.0.0 → 0.4.0.1
raw patch · 3 files changed
+8/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- numerus-closus.cabal +1/−1
- src/Control/NumerusClosus/Typed.hs +4/−4
- test/Spec.hs +3/−3
numerus-closus.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: numerus-closus-version: 0.4.0.0+version: 0.4.0.1 author: Gautier DI FOLCO maintainer: gautier.difolco@gmail.com category: Scheduling
src/Control/NumerusClosus/Typed.hs view
@@ -291,9 +291,9 @@ debit (x :&& y) at = case (debit x at, debit y at) of (Right x', Right y') -> Right $ x' :&& y'- (Left x', Left y') -> Left $ getMax $ Max x' <> Max y'- (Left x', _) -> Left $ getFirst $ First x'- (_, Left y') -> Left $ getLast $ Last y'+ (Left x', Left y') -> Left $ getLast $ Last x' <> Last y'+ (Left x', _) -> Left x'+ (_, Left y') -> Left y' -- | OR combinator type: allows a request if either rate limiter allows it. data a :|| b = a :|| b@@ -305,7 +305,7 @@ debit (x :|| y) at = case (debit x at, debit y at) of (Right x', Right y') -> Right $ x' :|| y'- (Left x', Left y') -> Left $ getMin $ Min x' <> Min y'+ (Left x', Left y') -> Left $ getFirst $ First x' <> First y' (Right x', _) -> Right $ x' :|| y (_, Right y') -> Right $ x :|| y'
test/Spec.hs view
@@ -29,7 +29,7 @@ genUTCTime :: Hedgehog.Gen UTCTime genUTCTime = do- s <- Gen.integral (Range.linear 0 86400)+ s <- Gen.integral (Range.linear @Integer 0 86400) pure $ addUTCTime (secondsToNominalDiffTime (fromIntegral s)) baseTime debitN :: Int -> UTCTime -> NC.RateLimiter -> Either NC.NextDebitable NC.RateLimiter@@ -260,14 +260,14 @@ describe "Properties" do it "finiteBucket allows exactly n then denies" $ hedgehog do- n <- forAll (Gen.integral (Range.linear 0 100))+ n <- forAll (Gen.integral (Range.linear @Integer 0 100)) let rl = NC.finiteBucket (NC.BucketSize n) case debitN (fromIntegral n) baseTime rl of Right rl' -> assertLeftNeverH $ NC.debit rl' baseTime Left _ -> Hedgehog.failure it "alwaysAllow never denies" $ hedgehog do- n <- forAll (Gen.integral (Range.linear 0 1000))+ n <- forAll (Gen.integral (Range.linear @Integer 0 1000)) case debitN (fromIntegral n) baseTime NC.alwaysAllow of Right _ -> pure () Left _ -> Hedgehog.failure