foldl 1.2.2 → 1.2.3
raw patch · 3 files changed
+19/−3 lines, 3 filesdep ~basedep ~vectorPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, vector
API changes (from Hackage documentation)
+ Control.Foldl: lookup :: Eq a => a -> Fold (a, b) (Maybe b)
Files
- README.md +1/−1
- foldl.cabal +2/−2
- src/Control/Foldl.hs +16/−0
README.md view
@@ -1,4 +1,4 @@-# `foldl` v1.2.2+# `foldl` v1.2.3 Use this `foldl` library when you want to compute multiple folds over a collection in one pass over the data without space leaks.
foldl.cabal view
@@ -1,5 +1,5 @@ Name: foldl-Version: 1.2.2+Version: 1.2.3 Cabal-Version: >=1.8.0.2 Build-Type: Simple License: BSD3@@ -31,7 +31,7 @@ primitive < 0.7 , text >= 0.11.2.0 && < 1.3 , transformers >= 0.2.0.0 && < 0.6 ,- vector >= 0.7 && < 0.12,+ vector >= 0.7 && < 0.13, containers < 0.6 , contravariant < 1.5 , profunctors < 5.3 ,
src/Control/Foldl.hs view
@@ -76,6 +76,7 @@ , notElem , find , index+ , lookup , elemIndex , findIndex , random@@ -154,6 +155,7 @@ , minimum , elem , notElem+ , lookup ) import qualified Data.Foldable as F@@ -671,6 +673,20 @@ else Left' (i + 1) _ -> x {-# INLINABLE findIndex #-}+++{-| @(lookup a)@ returns the element paired with the first matching item, or+ 'Nothing' if none matches+-}+lookup :: Eq a => a -> Fold (a,b) (Maybe b)+lookup a0 = Fold step Nothing' lazy+ where+ step x (a,b) = case x of+ Nothing' -> if a == a0+ then Just' b+ else Nothing'+ _ -> x+{-# INLINABLE lookup #-} data Pair3 a b c = Pair3 !a !b !c