packages feed

mono-traversable 1.0.15.2 → 1.0.15.3

raw patch · 6 files changed

+27/−127 lines, 6 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # ChangeLog for mono-traversable +## 1.0.15.3++* Compile with GHC 9.2 (`Option` removed from `base-4.16`)+  [#199](https://github.com/snoyberg/mono-traversable/issues/199)+ ## 1.0.15.2  * Support transformers 0.6.0.0 [#196](https://github.com/snoyberg/mono-traversable/issues/196)
mono-traversable.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           mono-traversable-version:        1.0.15.2+version:        1.0.15.3 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
src/Data/Containers.hs view
@@ -9,19 +9,13 @@  import Prelude hiding (lookup) import Data.Maybe (fromMaybe)-#if MIN_VERSION_containers(0, 5, 0) import qualified Data.Map.Strict as Map import qualified Data.IntMap.Strict as IntMap-#else-import qualified Data.Map as Map-import qualified Data.IntMap as IntMap-#endif import qualified Data.HashMap.Strict as HashMap import Data.Hashable (Hashable) import qualified Data.Set as Set import qualified Data.HashSet as HashSet import Data.Monoid (Monoid (..))-import Data.Semigroup (Semigroup) import Data.MonoTraversable (MonoFunctor(..), MonoFoldable, MonoTraversable, Element, GrowingAppend, ofoldl', otoList) import Data.Function (on) import qualified Data.List as List@@ -67,9 +61,7 @@     -- | Get a list of all of the keys in the container.     keys :: set -> [ContainerKey set] -#if MIN_VERSION_containers(0, 5, 0) -- | This instance uses the functions from "Data.Map.Strict".-#endif instance Ord k => SetContainer (Map.Map k v) where     type ContainerKey (Map.Map k v) = k     member = Map.member@@ -87,9 +79,7 @@     keys = Map.keys     {-# INLINE keys #-} -#if MIN_VERSION_containers(0, 5, 0) -- | This instance uses the functions from "Data.HashMap.Strict".-#endif instance (Eq key, Hashable key) => SetContainer (HashMap.HashMap key value) where     type ContainerKey (HashMap.HashMap key value) = key     member = HashMap.member@@ -107,9 +97,7 @@     keys = HashMap.keys     {-# INLINE keys #-} -#if MIN_VERSION_containers(0, 5, 0) -- | This instance uses the functions from "Data.IntMap.Strict".-#endif instance SetContainer (IntMap.IntMap value) where     type ContainerKey (IntMap.IntMap value) = Int     member = IntMap.member@@ -213,9 +201,7 @@     intersectionWithMap :: (value1 -> value2 -> value3)                         -> map value1 -> map value2 -> map value3 -#if MIN_VERSION_containers(0, 5, 0) -- | This instance uses the functions from "Data.Map.Strict".-#endif instance Ord key => PolyMap (Map.Map key) where     differenceMap = Map.difference     {-# INLINE differenceMap #-}@@ -225,9 +211,7 @@     intersectionWithMap = Map.intersectionWith     {-# INLINE intersectionWithMap #-} -#if MIN_VERSION_containers(0, 5, 0) -- | This instance uses the functions from "Data.HashMap.Strict".-#endif instance (Eq key, Hashable key) => PolyMap (HashMap.HashMap key) where     differenceMap = HashMap.difference     {-# INLINE differenceMap #-}@@ -237,9 +221,7 @@     intersectionWithMap = HashMap.intersectionWith     {-# INLINE intersectionWithMap #-} -#if MIN_VERSION_containers(0, 5, 0) -- | This instance uses the functions from "Data.IntMap.Strict".-#endif instance PolyMap IntMap.IntMap where     differenceMap = IntMap.difference     {-# INLINE differenceMap #-}@@ -568,9 +550,7 @@     filterMap :: IsMap map => (MapValue map -> Bool) -> map -> map     filterMap p = mapFromList . filter (p . snd) . mapToList -#if MIN_VERSION_containers(0, 5, 0) -- | This instance uses the functions from "Data.Map.Strict".-#endif instance Ord key => IsMap (Map.Map key value) where     type MapValue (Map.Map key value) = value     lookup = Map.lookup@@ -619,9 +599,7 @@     filterMap = Map.filter     {-# INLINE filterMap #-} -#if MIN_VERSION_containers(0, 5, 0) -- | This instance uses the functions from "Data.HashMap.Strict".-#endif instance (Eq key, Hashable key) => IsMap (HashMap.HashMap key value) where     type MapValue (HashMap.HashMap key value) = value     lookup = HashMap.lookup@@ -658,9 +636,7 @@     filterMap = HashMap.filter     {-# INLINE filterMap #-} -#if MIN_VERSION_containers(0, 5, 0) -- | This instance uses the functions from "Data.IntMap.Strict".-#endif instance IsMap (IntMap.IntMap value) where     type MapValue (IntMap.IntMap value) = value     lookup = IntMap.lookup@@ -703,10 +679,8 @@     {-# INLINE unionsWith #-}     mapWithKey = IntMap.mapWithKey     {-# INLINE mapWithKey #-}-#if MIN_VERSION_containers(0, 5, 0)     omapKeysWith = IntMap.mapKeysWith     {-# INLINE omapKeysWith #-}-#endif     filterMap = IntMap.filter     {-# INLINE filterMap #-} 
src/Data/MonoTraversable.hs view
@@ -30,11 +30,7 @@  import           Control.Applicative import           Control.Category-#if MIN_VERSION_base(4,8,0) import           Control.Monad        (Monad (..))-#else-import           Control.Monad        (Monad (..), liftM)-#endif import qualified Data.ByteString      as S import qualified Data.ByteString.Lazy as L import qualified Data.Foldable        as F@@ -48,7 +44,7 @@ import           Data.Word            (Word8) import Data.Int (Int, Int64) import           GHC.Exts             (build)-import           GHC.Generics         ((:.:), (:*:), (:+:)(..), K1(..), M1(..), Par1(..), Rec1(..), U1(..), V1(..))+import           GHC.Generics         ((:.:), (:*:), (:+:)(..), K1(..), M1(..), Par1(..), Rec1(..), U1(..), V1) import           Prelude              (Bool (..), const, Char, flip, IO, Maybe (..), Either (..),                                        (+), Integral, Ordering (..), compare, fromIntegral, Num, (>=),                                        (==), seq, otherwise, Eq, Ord, (-), (*))@@ -94,7 +90,14 @@ import qualified Data.Vector.Unboxed as U import qualified Data.Vector.Storable as VS import qualified Data.IntSet as IntSet-import Data.Semigroup (Semigroup, Option (..), Arg)+import Data.Semigroup+  ( Semigroup+-- Option has been removed in base-4.16 (GHC 9.2)+#if !MIN_VERSION_base(4,16,0)+  , Option (..)+#endif+  , Arg+  ) import qualified Data.ByteString.Unsafe as SU import Control.Monad.Trans.Identity (IdentityT) @@ -115,7 +118,9 @@ type instance Element (ViewR a) = a type instance Element (IntMap a) = a type instance Element IntSet = Int+#if !MIN_VERSION_base(4,16,0) type instance Element (Option a) = a+#endif type instance Element (NonEmpty a) = a type instance Element (Identity a) = a type instance Element (r -> a) = a@@ -188,7 +193,9 @@ instance MonoFunctor (ViewL a) instance MonoFunctor (ViewR a) instance MonoFunctor (IntMap a)+#if !MIN_VERSION_base(4,16,0) instance MonoFunctor (Option a)+#endif instance MonoFunctor (NonEmpty a) instance MonoFunctor (Identity a) instance MonoFunctor (r -> a)@@ -332,23 +339,13 @@      -- | Map each element of a monomorphic container to a monadic action,     -- evaluate these actions from left to right, and ignore the results.-#if MIN_VERSION_base(4,8,0)     omapM_ :: Applicative m => (Element mono -> m ()) -> mono -> m ()     omapM_ = otraverse_-#else-    omapM_ :: Monad m => (Element mono -> m ()) -> mono -> m ()-    omapM_ f = ofoldr ((>>) . f) (return ())-#endif     {-# INLINE omapM_ #-}      -- | 'oforM_' is 'omapM_' with its arguments flipped.-#if MIN_VERSION_base(4,8,0)     oforM_ :: Applicative m => mono -> (Element mono -> m ()) -> m ()     oforM_ = flip omapM_-#else-    oforM_ :: Monad m => mono -> (Element mono -> m ()) -> m ()-    oforM_ = flip omapM_-#endif     {-# INLINE oforM_ #-}      -- | Monadic fold over the elements of a monomorphic container, associating to the left.@@ -366,7 +363,7 @@     -- /See 'Data.NonNull.ofoldMap1' from "Data.NonNull" for a total version of this function./     ofoldMap1Ex :: Semigroup m => (Element mono -> m) -> mono -> m     ofoldMap1Ex f = fromMaybe (Prelude.error "Data.MonoTraversable.ofoldMap1Ex")-                       . getOption . ofoldMap (Option . Just . f)+                       . ofoldMap (Just . f)      -- | Right-associative fold of a monomorphic container with no base element.     --@@ -484,19 +481,10 @@             end = start `plusPtr` len             loop ptr                 | ptr >= end = evil (touchForeignPtr fptr) `seq`-#if MIN_VERSION_base(4,8,0)                     pure ()-#else-                    return ()-#endif                 | otherwise =-#if MIN_VERSION_base(4,8,0)                     f (evil (peek ptr)) *>                     loop (ptr `plusPtr` 1)-#else-                    f (evil (peek ptr)) >>-                    loop (ptr `plusPtr` 1)-#endif         loop start       where #if MIN_VERSION_bytestring(0,10,6)@@ -641,11 +629,7 @@         | i Prelude.<= 0 = GT         | otherwise = ocompareLength xs (i - 1) instance MonoFoldable (Maybe a) where-#if MIN_VERSION_base(4,8,0)     omapM_ _ Nothing = pure ()-#else-    omapM_ _ Nothing = return ()-#endif     omapM_ f (Just x) = f x     {-# INLINE omapM_ #-} instance MonoFoldable (Tree a)@@ -657,7 +641,9 @@ instance MonoFoldable (ViewL a) instance MonoFoldable (ViewR a) instance MonoFoldable (IntMap a)+#if !MIN_VERSION_base(4,16,0) instance MonoFoldable (Option a)+#endif instance MonoFoldable (NonEmpty a) instance MonoFoldable (Identity a) instance MonoFoldable (Map k v) where@@ -787,11 +773,7 @@     ofoldr1Ex _ (Right x) = x     ofoldl1Ex' _ (Left _) = Prelude.error "ofoldl1Ex' on Either"     ofoldl1Ex' _ (Right x) = x-#if MIN_VERSION_base(4,8,0)     omapM_ _ (Left _) = pure ()-#else-    omapM_ _ (Left _) = return ()-#endif     omapM_ f (Right x) = f x     {-# INLINE ofoldMap #-}     {-# INLINE ofoldr #-}@@ -910,11 +892,7 @@ -- | Perform all actions in the given container -- -- @since 1.0.0-#if MIN_VERSION_base(4,8,0) osequence_ :: (Applicative m, MonoFoldable mono, Element mono ~ (m ())) => mono -> m ()-#else-osequence_ :: (Monad m, MonoFoldable mono, Element mono ~ (m ())) => mono -> m ()-#endif osequence_ = omapM_ id {-# INLINE osequence_ #-} @@ -1020,45 +998,23 @@     -- | Map each element of a monomorphic container to a monadic action,     -- evaluate these actions from left to right, and     -- collect the results.-#if MIN_VERSION_base(4,8,0)     omapM :: Applicative m => (Element mono -> m (Element mono)) -> mono -> m mono     omapM = otraverse-#else-    omapM :: Monad m => (Element mono -> m (Element mono)) -> mono -> m mono-    default omapM :: (Traversable t, mono ~ t a, a ~ Element mono, Monad m) => (Element mono -> m (Element mono)) -> mono -> m mono-    omapM = mapM-#endif     {-# INLINE otraverse #-}     {-# INLINE omapM #-}  instance MonoTraversable S.ByteString where     otraverse f = fmap S.pack . traverse f . S.unpack     {-# INLINE otraverse #-}-#if !MIN_VERSION_base(4,8,0)-    omapM f = liftM S.pack . mapM f . S.unpack-    {-# INLINE omapM #-}-#endif instance MonoTraversable L.ByteString where     otraverse f = fmap L.pack . traverse f . L.unpack     {-# INLINE otraverse #-}-#if !MIN_VERSION_base(4,8,0)-    omapM f = liftM L.pack . mapM f . L.unpack-    {-# INLINE omapM #-}-#endif instance MonoTraversable T.Text where     otraverse f = fmap T.pack . traverse f . T.unpack     {-# INLINE otraverse #-}-#if !MIN_VERSION_base(4,8,0)-    omapM f = liftM T.pack . mapM f . T.unpack-    {-# INLINE omapM #-}-#endif instance MonoTraversable TL.Text where     otraverse f = fmap TL.pack . traverse f . TL.unpack     {-# INLINE otraverse #-}-#if !MIN_VERSION_base(4,8,0)-    omapM f = liftM TL.pack . mapM f . TL.unpack-    {-# INLINE omapM #-}-#endif instance MonoTraversable [a] instance MonoTraversable (Maybe a) instance MonoTraversable (Tree a)@@ -1066,7 +1022,9 @@ instance MonoTraversable (ViewL a) instance MonoTraversable (ViewR a) instance MonoTraversable (IntMap a)+#if !MIN_VERSION_base(4,16,0) instance MonoTraversable (Option a)+#endif instance MonoTraversable (NonEmpty a) instance MonoTraversable (Identity a) instance MonoTraversable (Map k v)@@ -1075,33 +1033,20 @@ instance U.Unbox a => MonoTraversable (U.Vector a) where     -- FIXME do something more efficient     otraverse f = fmap U.fromList . traverse f . U.toList-#if MIN_VERSION_base(4,8,0)     omapM = otraverse-#else-    omapM = U.mapM-#endif     {-# INLINE otraverse #-}     {-# INLINE omapM #-} instance VS.Storable a => MonoTraversable (VS.Vector a) where     -- FIXME do something more efficient     otraverse f = fmap VS.fromList . traverse f . VS.toList-#if MIN_VERSION_base(4,8,0)     omapM = otraverse-#else-    omapM = VS.mapM-#endif     {-# INLINE otraverse #-}     {-# INLINE omapM #-} instance MonoTraversable (Either a b) where     otraverse _ (Left a) = pure (Left a)     otraverse f (Right b) = fmap Right (f b)-#if MIN_VERSION_base(4,8,0)     omapM _ (Left a) = pure (Left a)     omapM f (Right b) = fmap Right (f b)-#else-    omapM _ (Left a) = return (Left a)-    omapM f (Right b) = liftM Right (f b)-#endif     {-# INLINE otraverse #-}     {-# INLINE omapM #-} instance MonoTraversable (a, b)@@ -1142,11 +1087,7 @@ {-# INLINE ofor #-}  -- | 'oforM' is 'omapM' with its arguments flipped.-#if MIN_VERSION_base(4,8,0) oforM :: (MonoTraversable mono, Applicative f) => mono -> (Element mono -> f (Element mono)) -> f mono-#else-oforM :: (MonoTraversable mono, Monad f) => mono -> (Element mono -> f (Element mono)) -> f mono-#endif oforM = flip omapM {-# INLINE oforM #-} @@ -1209,7 +1150,9 @@ -- Applicative instance MonoPointed [a] instance MonoPointed (Maybe a)+#if !MIN_VERSION_base(4,16,0) instance MonoPointed (Option a)+#endif instance MonoPointed (NonEmpty a) instance MonoPointed (Identity a) instance MonoPointed (Vector a)
src/Data/MonoTraversable/Unprefixed.hs view
@@ -14,7 +14,6 @@  import Data.Int (Int64) import Data.MonoTraversable-import Data.Semigroup (Semigroup) import Data.Monoid (Monoid) import Control.Applicative (Applicative) @@ -93,25 +92,15 @@ -- | Synonym for 'omapM_' -- -- @since 1.0.0-#if MIN_VERSION_base(4,8,0) mapM_ :: (MonoFoldable mono, Applicative m)       => (Element mono -> m ()) -> mono -> m ()-#else-mapM_ :: (MonoFoldable mono, Monad m)-      => (Element mono -> m ()) -> mono -> m ()-#endif mapM_ = omapM_  -- | Synonym for 'oforM_' -- -- @since 1.0.0-#if MIN_VERSION_base(4,8,0) forM_ :: (MonoFoldable mono, Applicative m)       => mono -> (Element mono -> m ()) -> m ()-#else-forM_ :: (MonoFoldable mono, Monad m)-      => mono -> (Element mono -> m ()) -> m ()-#endif forM_ = oforM_  -- | Synonym for 'ofoldlM'@@ -227,9 +216,5 @@ -- | Synonym for 'osequence_' -- -- @since 1.0.0-#if MIN_VERSION_base(4,8,0) sequence_ :: (Applicative m, MonoFoldable mono, Element mono ~ (m ())) => mono -> m ()-#else-sequence_ :: (Monad m, MonoFoldable mono, Element mono ~ (m ())) => mono -> m ()-#endif sequence_ = osequence_
src/Data/NonNull.hs view
@@ -44,15 +44,11 @@ import Prelude hiding (head, tail, init, last, reverse, seq, filter, replicate, maximum, minimum) import Control.Arrow (second) import Control.Exception.Base (Exception, throw)-#if !MIN_VERSION_base(4,8,0)-import Control.Monad (liftM)-#endif import Data.Data import qualified Data.List.NonEmpty as NE import Data.Maybe (fromMaybe) import Data.MonoTraversable import Data.Sequences-import Data.Semigroup (Semigroup (..)) import Control.Monad.Trans.State.Strict (evalState, state)  data NullError = NullError String deriving (Show, Typeable)@@ -70,10 +66,7 @@ instance MonoTraversable mono => MonoTraversable (NonNull mono) where     otraverse f (NonNull x) = fmap NonNull (otraverse f x)     {-# INLINE otraverse #-}-#if !MIN_VERSION_base(4,8,0)-    omapM f (NonNull x) = liftM NonNull (omapM f x)-    {-# INLINE omapM #-}-#endif+ instance GrowingAppend mono => GrowingAppend (NonNull mono)  instance (Semigroup mono, GrowingAppend mono) => Semigroup (NonNull mono) where