packages feed

extra 1.7.7 → 1.7.8

raw patch · 4 files changed

+66/−5 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Foldable.Extra: allM :: (Foldable f, Monad m) => (a -> m Bool) -> f a -> m Bool
+ Data.Foldable.Extra: andM :: (Foldable f, Monad m) => f (m Bool) -> m Bool
+ Data.Foldable.Extra: anyM :: (Foldable f, Monad m) => (a -> m Bool) -> f a -> m Bool
+ Data.Foldable.Extra: findM :: (Foldable f, Monad m) => (a -> m Bool) -> f a -> m (Maybe a)
+ Data.Foldable.Extra: firstJustM :: (Foldable f, Monad m) => (a -> m (Maybe b)) -> f a -> m (Maybe b)
+ Data.Foldable.Extra: orM :: (Foldable f, Monad m) => f (m Bool) -> m Bool
+ Data.Foldable.Extra: product' :: (Foldable f, Num a) => f a -> a
+ Data.Foldable.Extra: productOn' :: (Foldable f, Num b) => (a -> b) -> f a -> b
+ Data.Foldable.Extra: sum' :: (Foldable f, Num a) => f a -> a
+ Data.Foldable.Extra: sumOn' :: (Foldable f, Num b) => (a -> b) -> f a -> b

Files

CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for Extra +1.7.8, released 2020-09-12+    #68, make sure Data.Foldable.Extra is exposed 1.7.7, released 2020-08-25     #67, defer to System.IO readFile', hGetContents' in GHC 9.0 1.7.6, released 2020-08-21
Generate.hs view
@@ -19,7 +19,7 @@ main = do     src <- readFile "extra.cabal"     let mods = filter (isSuffixOf ".Extra") $ map trim $ lines src-    ifaces <- forM mods $ \mod -> do+    ifaces <- forM (mods \\ exclude) $ \mod -> do         src <- readFile $ joinPath ("src" : split (== '.') mod) <.> "hs"         let funcs = filter validIdentifier $ takeWhile (/= "where") $                     words $ replace "," " " $ drop1 $ dropWhile (/= '(') $@@ -69,10 +69,12 @@     when (Just x /= old) $         writeFileBinary file x +exclude :: [String]+exclude = ["Data.Foldable.Extra"] -- because all their imports clash+ hidden :: String -> [String]-hidden "Data.List.NonEmpty.Extra" = [ "cons", "snoc", "sortOn", "union", "unionBy"-                                    , "nubOrd", "nubOrdBy", "nubOrdOn"-                                    ]+hidden "Data.List.NonEmpty.Extra" = words+    "cons snoc sortOn union unionBy nubOrd nubOrdBy nubOrdOn" hidden _ = []  notHidden :: String -> String -> Bool
extra.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.18 build-type:         Simple name:               extra-version:            1.7.7+version:            1.7.8 license:            BSD3 license-file:       LICENSE category:           Development@@ -47,6 +47,7 @@         Control.Concurrent.Extra         Control.Exception.Extra         Control.Monad.Extra+        Data.Foldable.Extra         Data.Either.Extra         Data.IORef.Extra         Data.List.Extra
+ src/Data/Foldable/Extra.hs view
@@ -0,0 +1,56 @@+module Data.Foldable.Extra+    ( module Data.Foldable+    , sum'+    , product'+    , sumOn'+    , productOn'+    , anyM+    , allM+    , orM+    , andM+    , findM+    , firstJustM+    ) where++import Data.Foldable+import qualified Control.Monad.Extra as MX++-- | A generalization of 'Data.List.Extra.sum'' to 'Foldable' instances.+sum' :: (Foldable f, Num a) => f a -> a+sum' = foldl' (+) 0++-- | A generalization of 'Data.List.Extra.product'' to 'Foldable' instances.+product' :: (Foldable f, Num a) => f a -> a+product' = foldl' (*) 1++-- | A generalization of 'Data.List.Extra.sumOn'' to 'Foldable' instances.+sumOn' :: (Foldable f, Num b) => (a -> b) -> f a -> b+sumOn' f = foldl' (\acc x -> acc + f x) 0++-- | A generalization of 'Data.List.Extra.productOn'' to 'Foldable' instances.+productOn' :: (Foldable f, Num b) => (a -> b) -> f a -> b+productOn' f = foldl' (\acc x -> acc * f x) 1++-- | A generalization of 'Control.Monad.Extra.anyM' to 'Foldable' instances. Retains the short-circuiting behaviour.+anyM :: (Foldable f, Monad m) => (a -> m Bool) -> f a -> m Bool+anyM p = foldr ((MX.||^) . p) (pure False)++-- | A generalization of 'Control.Monad.Extra.allM' to 'Foldable' instances. Retains the short-circuiting behaviour.+allM :: (Foldable f, Monad m) => (a -> m Bool) -> f a -> m Bool+allM p = foldr ((MX.&&^) . p) (pure True)++-- | A generalization of 'Control.Monad.Extra.orM' to 'Foldable' instances. Retains the short-circuiting behaviour.+orM :: (Foldable f, Monad m) => f (m Bool) -> m Bool+orM = anyM id++-- | A generalization of 'Control.Monad.Extra.andM' to 'Foldable' instances. Retains the short-circuiting behaviour.+andM :: (Foldable f, Monad m) => f (m Bool) -> m Bool+andM = allM id++-- | A generalization of 'Control.Monad.Extra.findM' to 'Foldable' instances.+findM :: (Foldable f, Monad m) => (a -> m Bool) -> f a -> m (Maybe a)+findM p = foldr (\x -> MX.ifM (p x) (pure $ Just x)) (pure Nothing)++-- | A generalization of 'Control.Monad.Extra.firstJustM' to 'Foldable' instances.+firstJustM :: (Foldable f, Monad m) => (a -> m (Maybe b)) -> f a -> m (Maybe b)+firstJustM p = MX.firstJustM p . toList