foldl 1.1.5 → 1.1.6
raw patch · 2 files changed
+28/−2 lines, 2 files
Files
- foldl.cabal +1/−1
- src/Control/Foldl.hs +27/−1
foldl.cabal view
@@ -1,5 +1,5 @@ Name: foldl-Version: 1.1.5+Version: 1.1.6 Cabal-Version: >=1.8.0.2 Build-Type: Simple License: BSD3
src/Control/Foldl.hs view
@@ -64,7 +64,9 @@ , sum , product , maximum+ , maximumBy , minimum+ , minimumBy , elem , notElem , find@@ -549,11 +551,33 @@ maximum = _Fold1 max {-# INLINABLE maximum #-} +{-| Computes the maximum element with respect to the given comparison+ function+-}+maximumBy :: (a -> a -> Ordering) -> Fold a (Maybe a)+maximumBy cmp = _Fold1 max'+ where + max' x y = case cmp x y of+ GT -> x+ _ -> y+{-# INLINABLE maximumBy #-}+ -- | Computes the minimum element minimum :: Ord a => Fold a (Maybe a) minimum = _Fold1 min {-# INLINABLE minimum #-} +{-| Computes the minimum element with respect to the given comparison+ function+-}+minimumBy :: (a -> a -> Ordering) -> Fold a (Maybe a)+minimumBy cmp = _Fold1 min'+ where + min' x y = case cmp x y of+ GT -> y+ _ -> x+{-# INLINABLE minimumBy #-}+ {-| @(elem a)@ returns 'True' if the container has an element equal to @a@, 'False' otherwise -}@@ -927,6 +951,7 @@ > handles _1 :: Fold a r -> Fold (a, b) r > handles _Left :: Fold a r -> Fold (Either a b) r > handles traverse :: Traversable t => Fold a r -> Fold (t a) r+> handles folded :: Foldable t => Fold a r -> Fold (t a) r >>> fold (handles traverse sum) [[1..5],[6..10]] 55@@ -934,7 +959,7 @@ >>> fold (handles (traverse.traverse) sum) [[Nothing, Just 2, Just 7],[Just 13, Nothing, Just 20]] 42 ->>> fold (handles (filtered even) sum) [1,3,5,7,21,21]+>>> fold (handles (filtered even) sum) [1..10] 42 >>> fold (handles _2 mconcat) [(1,"Hello "),(2,"World"),(3,"!")]@@ -978,6 +1003,7 @@ > handlesM _1 :: FoldM m a r -> FoldM (a, b) r > handlesM _Left :: FoldM m a r -> FoldM (Either a b) r > handlesM traverse :: Traversable t => FoldM m a r -> FoldM m (t a) r+> handlesM folded :: Foldable t => FoldM m a r -> FoldM m (t a) r `handlesM` obeys these laws: