packages feed

ListLike 3.1.6 → 3.1.7

raw patch · 4 files changed

+32/−24 lines, 4 filesdep ~base

Dependency ranges changed: base

Files

ListLike.cabal view
@@ -1,5 +1,5 @@ Name: ListLike-Version: 3.1.6+Version: 3.1.7 License: BSD3 Maintainer: John Lato <jwlato@gmail.com> Author: John Goerzen@@ -43,7 +43,7 @@   Buildable: False   Main-Is: runtests.hs   HS-Source-Dirs: testsrc, .-  Extensions: ExistentialQuantification, OverlappingInstances,+  Extensions: ExistentialQuantification       UndecidableInstances, CPP  source-repository head
src/Data/ListLike/Base.hs view
@@ -355,12 +355,6 @@          of the item.  This can have performance benefits with some types. -}     rigidMapM :: Monad m => (item -> m item) -> full -> m full     rigidMapM = mapM-            -    {- | A map in monad space, discarding results.  Same as-       @'sequence_' . 'map'@ -}-    mapM_ :: (Monad m) => (item -> m b) -> full -> m ()-    mapM_ func l = sequence_ mapresult-            where mapresult = asTypeOf (map func l) []       ------------------------------ "Set" operations@@ -604,7 +598,7 @@     findIndex = L.findIndex     sequence = M.sequence . toList     -- mapM = M.mapM-    mapM_ = M.mapM_+    -- mapM_ = M.mapM_     nub = L.nub     delete = L.delete     deleteFirsts = (L.\\)@@ -639,9 +633,3 @@     | null a = empty     | null b = empty     | otherwise = cons (f (head a) (head b)) (zipWith f (tail a) (tail b))--{- | Evaluate each action, ignoring the results -}-sequence_ :: (Monad m, ListLike mfull (m item)) => mfull -> m ()-sequence_ l = foldr (>>) (return ()) l--
src/Data/ListLike/FoldableLL.hs view
@@ -28,9 +28,9 @@     (-- * FoldableLL Class      FoldableLL(..),      -- * Utilities-     fold, foldMap+     fold, foldMap, foldM, sequence_, mapM_     ) where -import Prelude hiding (foldl, foldr, foldr1)+import Prelude hiding (foldl, foldr, foldr1, sequence_, mapM_) import qualified Data.Foldable as F import Data.Monoid import Data.Maybe@@ -102,3 +102,17 @@     foldr1 = F.foldr1     foldr' = F.foldr' -}++-- Based on http://stackoverflow.com/a/12881193/1333025+{- | Monadic version of left fold, similar to 'Control.Monad.foldM'. -}+foldM :: (Monad m, FoldableLL full item) => (a -> item -> m a) -> a -> full -> m a+foldM f z xs = foldr (\x rest a -> f a x >>= rest) return xs z++{- | A map in monad space, discarding results. -}+mapM_ :: (Monad m, FoldableLL full item) => (item -> m b) -> full -> m ()+mapM_ func = foldr ((>>) . func) (return ())++{- | Evaluate each action, ignoring the results.+   Same as @'mapM_' 'id'@. -}+sequence_ :: (Monad m, FoldableLL full (m item)) => full -> m ()+sequence_ = mapM_ id
src/Data/ListLike/Instances.hs view
@@ -36,6 +36,8 @@                        product, repeat, replicate, cycle, take, drop,                        splitAt, elem, notElem, unzip, lines, words,                        unlines, unwords)+import qualified Prelude as P+import           Control.Monad import qualified Data.List as L import qualified Data.Sequence as S import           Data.Sequence ((><), (|>), (<|))@@ -145,9 +147,11 @@     elemIndices x = fromList . BS.elemIndices x     findIndex = BS.findIndex     findIndices x = fromList . BS.findIndices x-    --sequence = BS.sequence-    --mapM = BS.mapM-    --mapM_ = BS.mapM_+    -- the default definitions don't work well for array-like things, so+    -- do monadic stuff via a list instead+    sequence  = liftM fromList . P.sequence  . toList+    mapM func = liftM fromList . P.mapM func . toList+    mapM_ func = P.mapM_ func . toList     --nub = BS.nub     --delete = BS.delete     --deleteFirsts = BS.deleteFirsts@@ -254,6 +258,9 @@     --elemIndices x = fromList . L.map fromIntegral . BSL.elemIndices x     findIndex f = mi64toi . BSL.findIndex f     --findIndices x = fromList . L.map fromIntegral . BSL.findIndices x+    sequence  = liftM fromList . P.sequence  . toList+    mapM func = liftM fromList . P.mapM func . toList+    mapM_ func = P.mapM_ func . toList     --sequence = BSL.sequence     --mapM = BSL.mapM     --mapM_ = BSL.mapM_@@ -392,10 +399,10 @@     elemIndices i = fromList . L.elemIndices i . toList     findIndex f = L.findIndex f . toList     findIndices f = fromList . L.findIndices f . toList-    -- sequence = M.sequence . toList-    -- mapM f = M.mapM f . toList+    sequence  = liftM fromList . P.sequence  . toList+    mapM func = liftM fromList . P.mapM func . toList+    mapM_ func = P.mapM_ func . toList     -- rigidMapM = mapM-    -- mapM_ f = M.mapM_ f . toList     nub = fromList . L.nub . toList     -- delete     -- deleteFirsts@@ -532,7 +539,6 @@     findIndices p = fromList . S.findIndicesL p     --sequence =     --mapM f =-    mapM_ = F.mapM_     --nub =     --delete =     --deleteFirsts =