packages feed

mono-traversable 1.0.17.0 → 1.0.20.0

raw patch · 6 files changed

+64/−6 lines, 6 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Data.Containers: filterWithKey :: IsMap map => (ContainerKey map -> MapValue map -> Bool) -> map -> map
+ Data.MonoTraversable: instance Data.MonoTraversable.MonoFoldable (f a) => Data.MonoTraversable.MonoFoldable (Data.Functor.Reverse.Reverse f a)
+ Data.MonoTraversable: instance Data.MonoTraversable.MonoFunctor (f a) => Data.MonoTraversable.MonoFunctor (Data.Functor.Reverse.Reverse f a)
+ Data.MonoTraversable: instance Data.MonoTraversable.MonoPointed Data.Text.Internal.Builder.Builder
+ Data.MonoTraversable: instance Data.MonoTraversable.MonoTraversable (f a) => Data.MonoTraversable.MonoTraversable (Data.Functor.Reverse.Reverse f a)
- Data.Containers: filterMap :: (IsMap map, IsMap map) => (MapValue map -> Bool) -> map -> map
+ Data.Containers: filterMap :: IsMap map => (MapValue map -> Bool) -> map -> map

Files

ChangeLog.md view
@@ -1,5 +1,23 @@ # ChangeLog for mono-traversable +## 1.0.20.0++* Added instances for [`Reverse`](https://hackage.haskell.org/package/transformers-0.6.1.1/docs/Data-Functor-Reverse.html#t:Reverse) data structure.++## 1.0.19.1++* Removed 'highly experimental' warning haddock comment from Data.Containers.++## 1.0.19.0++* Added `filterWithKey` to `IsMap`.+  [#232](https://github.com/snoyberg/mono-traversable/pull/232)++## 1.0.18.0++* Added MonoPointed instance for text Builder+  [#225](https://github.com/snoyberg/mono-traversable/pull/225)+ ## 1.0.17.0  * Added `inits`, `tails`, `initTails` to class `IsSequence` with tests and benchmarks for `initTails`.
mono-traversable.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0.+-- This file has been generated from package.yaml by hpack version 0.37.0. -- -- see: https://github.com/sol/hpack  name:           mono-traversable-version:        1.0.17.0+version:        1.0.20.0 synopsis:       Type classes for mapping, folding, and traversing monomorphic containers description:    Please see the README at <https://www.stackage.org/package/mono-traversable> category:       Data@@ -57,6 +57,8 @@   hs-source-dirs:       test   ghc-options: -O0+  build-tool-depends:+      hspec-discover:hspec-discover   build-depends:       HUnit     , QuickCheck
src/Data/Containers.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE CPP #-}--- | Warning: This module should be considered highly experimental.+{-# LANGUAGE TypeOperators #-} module Data.Containers where  import Prelude hiding (lookup)@@ -547,9 +547,16 @@     -- | Filter values in a map.     --     -- @since 1.0.9.0-    filterMap :: IsMap map => (MapValue map -> Bool) -> map -> map-    filterMap p = mapFromList . filter (p . snd) . mapToList+    filterMap :: (MapValue map -> Bool) -> map -> map+    filterMap = filterWithKey . const +    -- | Equivalent to 'filterMap', but the function accepts the key,+    -- as well as the value.+    --+    -- @since 1.0.19.0+    filterWithKey :: (ContainerKey map -> MapValue map -> Bool) -> map -> map+    filterWithKey p = mapFromList . filter (uncurry p) . mapToList+ -- | This instance uses the functions from "Data.Map.Strict". instance Ord key => IsMap (Map.Map key value) where     type MapValue (Map.Map key value) = value@@ -598,6 +605,8 @@     {-# INLINE omapKeysWith #-}     filterMap = Map.filter     {-# INLINE filterMap #-}+    filterWithKey = Map.filterWithKey+    {-# INLINE filterWithKey #-}  -- | This instance uses the functions from "Data.HashMap.Strict". instance (Eq key, Hashable key) => IsMap (HashMap.HashMap key value) where@@ -635,6 +644,8 @@     --mapKeysWith = HashMap.mapKeysWith     filterMap = HashMap.filter     {-# INLINE filterMap #-}+    filterWithKey = HashMap.filterWithKey+    {-# INLINE filterWithKey #-}  -- | This instance uses the functions from "Data.IntMap.Strict". instance IsMap (IntMap.IntMap value) where@@ -683,6 +694,8 @@     {-# INLINE omapKeysWith #-}     filterMap = IntMap.filter     {-# INLINE filterMap #-}+    filterWithKey = IntMap.filterWithKey+    {-# INLINE filterWithKey #-}  instance Eq key => IsMap [(key, value)] where     type MapValue [(key, value)] = value
src/Data/MonoTraversable.hs view
@@ -37,10 +37,11 @@ import qualified Data.Foldable        as F import           Data.Functor import           Data.Maybe           (fromMaybe)-import           Data.Monoid (Monoid (..), Any (..), All (..))+import           Data.Monoid (Dual(..), Monoid (..), Any (..), All (..)) import           Data.Proxy import qualified Data.Text            as T import qualified Data.Text.Lazy       as TL+import qualified Data.Text.Lazy.Builder as TB import           Data.Traversable import           Data.Word            (Word8) import Data.Int (Int, Int64)@@ -55,6 +56,7 @@ import Foreign.Ptr (plusPtr) import Foreign.ForeignPtr (touchForeignPtr) import Foreign.Storable (peek)+import Control.Applicative.Backwards (Backwards (..)) import Control.Arrow (Arrow) import Data.Tree (Tree (..)) import Data.Sequence (Seq, ViewL (..), ViewR (..))@@ -64,6 +66,7 @@ import qualified Data.List as List import Data.List.NonEmpty (NonEmpty) import Data.Functor.Identity (Identity)+import Data.Functor.Reverse (Reverse (..)) import Data.Map (Map) import qualified Data.Map.Strict as Map import Data.HashMap.Strict (HashMap)@@ -111,6 +114,8 @@ type instance Element B.Builder = Word8 type instance Element T.Text = Char type instance Element TL.Text = Char+-- | @since 1.0.18.0+type instance Element TB.Builder = Char type instance Element [a] = a type instance Element (IO a) = a type instance Element (ZipList a) = a@@ -165,6 +170,7 @@ type instance Element (U1 a)        = a type instance Element (V1 a)        = a type instance Element (Proxy a)     = a+type instance Element (Reverse f a) = Element (f a)  -- | Monomorphic containers that can be mapped over. class MonoFunctor mono where@@ -252,6 +258,9 @@ instance VS.Storable a => MonoFunctor (VS.Vector a) where     omap = VS.map     {-# INLINE omap #-}+-- | @since 1.0.20.0+instance MonoFunctor (f a) => MonoFunctor (Reverse f a) where+    omap f (Reverse t) = Reverse (omap f t)  -- | @'replaceElem' old new@ replaces all @old@ elements with @new@. --@@ -820,6 +829,13 @@ instance MonoFoldable (V1 a) -- | @since 1.0.11.0 instance MonoFoldable (Proxy a)+-- | @since 1.0.20.0+instance MonoFoldable (f a) => MonoFoldable (Reverse f a) where+    ofoldMap f (Reverse t) = getDual (ofoldMap (Dual . f) t)+    ofoldr f z (Reverse t) = ofoldl' (flip f) z t+    ofoldl' f z (Reverse t) = ofoldr (flip f) z t+    ofoldr1Ex f (Reverse t) = ofoldl1Ex' (flip f) t+    ofoldl1Ex' f (Reverse t) = ofoldr1Ex (flip f) t  -- | Safe version of 'headEx'. --@@ -1083,6 +1099,9 @@ instance MonoTraversable (V1 a) -- | @since 1.0.11.0 instance MonoTraversable (Proxy a)+-- | @since 1.0.20.0+instance (MonoTraversable (f a)) => MonoTraversable (Reverse f a) where+    otraverse f (Reverse t) = (fmap Reverse . forwards) (otraverse (Backwards . f) t)  -- | 'ofor' is 'otraverse' with its arguments flipped. ofor :: (MonoTraversable mono, Applicative f) => mono -> (Element mono -> f (Element mono)) -> f mono@@ -1152,6 +1171,10 @@     {-# INLINE opoint #-} instance MonoPointed TL.Text where     opoint = TL.singleton+    {-# INLINE opoint #-}+-- | @since 1.0.18.0+instance MonoPointed TB.Builder where+    opoint = TB.singleton     {-# INLINE opoint #-}  -- Applicative
src/Data/MonoTraversable/Unprefixed.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} -- | The functions in "Data.MonoTraversable" are all prefixed with the letter -- @o@ to avoid conflicts with their polymorphic counterparts. This module -- exports the same identifiers without the prefix, for all cases where the
src/Data/Sequences.hs view
@@ -5,6 +5,7 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE TypeOperators #-} -- | Abstractions over sequential data structures, like lists and vectors. module Data.Sequences where