indexed-traversable 0.1.3 → 0.1.4
raw patch · 4 files changed
+20/−112 lines, 4 filesdep −base-orphansdep −generic-derivingdep −ghc-primdep ~basedep ~containersdep ~transformers
Dependencies removed: base-orphans, generic-deriving, ghc-prim, semigroups, tagged, transformers-compat, void
Dependency ranges changed: base, containers, transformers
Files
- Changelog.md +4/−0
- indexed-traversable.cabal +9/−36
- src/CoerceCompat.hs +0/−14
- src/WithIndex.hs +7/−62
Changelog.md view
@@ -1,3 +1,7 @@+# 0.1.4 [2024-05-dd]++- Drop support for GHCs prior 8.6.5+ # 0.1.3 [2023-10-04] - Add `Foldable1WithIndex1` type-class, an indexed version of `Foldable1`.
indexed-traversable.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: indexed-traversable-version: 0.1.3+version: 0.1.4 build-type: Simple license: BSD2 license-file: LICENSE@@ -34,23 +34,15 @@ extra-source-files: Changelog.md tested-with:- GHC ==7.0.4- || ==7.2.2- || ==7.4.2- || ==7.6.3- || ==7.8.4- || ==7.10.3- || ==8.0.2- || ==8.2.2- || ==8.4.4- || ==8.6.5+ GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8- || ==9.4.7- || ==9.6.3- || ==9.8.1+ || ==9.4.8+ || ==9.6.5+ || ==9.8.2+ || ==9.10.1 source-repository head type: git@@ -59,7 +51,6 @@ library default-language: Haskell2010- ghc-options: -Wall hs-source-dirs: src other-modules: CoerceCompat@@ -74,27 +65,9 @@ build-depends: array >=0.3.0.2 && <0.6- , base >=4.3 && <4.20- , containers >=0.4.0.0 && <0.7- , transformers >=0.3.0.0 && <0.7-- if !impl(ghc >=7.8)- build-depends: tagged >=0.8.5 && <0.9-- if !impl(ghc >=7.10)- build-depends: void >=0.7.2 && <0.8-- if !impl(ghc >=8.0)- build-depends:- base-orphans >=0.8.3 && <0.10- , semigroups >=0.18.4 && <0.21- , transformers-compat >=0.6.6 && <0.8+ , base >=4.12 && <4.21+ , containers >=0.6.0.1 && <0.8+ , transformers >=0.5.6.0 && <0.7 if !impl(ghc >=9.6) build-depends: foldable1-classes-compat >=0.1 && <0.2-- if (impl(ghc >=7.0) && impl(ghc <7.6))- build-depends: ghc-prim-- if (impl(ghc >=7.0) && impl(ghc <7.2))- build-depends: generic-deriving >=1.14 && <1.15
src/CoerceCompat.hs view
@@ -1,29 +1,15 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif module CoerceCompat where -#if __GLASGOW_HASKELL__ >=708 import Data.Coerce (Coercible, coerce)-#else-import Unsafe.Coerce (unsafeCoerce)-#endif --#if __GLASGOW_HASKELL__ >=708 (#.) :: Coercible b c => (b -> c) -> (a -> b) -> (a -> c) _ #. x = coerce x (#..) :: Coercible b c => (b -> c) -> (i -> a -> b) -> (i -> a -> c) _ #.. x = coerce x-#else-(#.) :: (b -> c) -> (a -> b) -> (a -> c)-_ #. x = unsafeCoerce x -(#..) :: (b -> c) -> (i -> a -> b) -> (i -> a -> c)-_ #.. x = unsafeCoerce x-#endif infixr 9 #., #.. {-# INLINE (#.) #-} {-# INLINE (#..) #-}
src/WithIndex.hs view
@@ -1,26 +1,14 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE GADTs #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE Safe #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-}--{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704-{-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif--#if __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE DefaultSignatures #-}-#endif--#if __GLASGOW_HASKELL__ >= 706-{-# LANGUAGE PolyKinds #-}-#endif module WithIndex where import Prelude@@ -28,7 +16,7 @@ flip, id, seq, snd, ($!), ($), (.)) import Control.Applicative- (Applicative (..), Const (..), ZipList (..), (<$>), liftA2)+ (Applicative (..), Const (..), ZipList (..), liftA2, (<$>)) import Control.Applicative.Backwards (Backwards (..)) import Control.Monad.Trans.Identity (IdentityT (..)) import Control.Monad.Trans.Reader (ReaderT (..))@@ -53,15 +41,9 @@ import Data.Tree (Tree (..)) import Data.Void (Void) -#if __GLASGOW_HASKELL__ >= 702 import GHC.Generics (K1 (..), Par1 (..), Rec1 (..), U1 (..), V1, (:*:) (..), (:+:) (..), (:.:) (..))-#else-import Generics.Deriving- (K1 (..), Par1 (..), Rec1 (..), U1 (..), V1, (:*:) (..), (:+:) (..),- (:.:) (..))-#endif import qualified Data.Array as Array import qualified Data.IntMap as IntMap@@ -90,11 +72,9 @@ -- | Map with access to the index. imap :: (i -> a -> b) -> f a -> f b -#if __GLASGOW_HASKELL__ >= 704 default imap :: TraversableWithIndex i f => (i -> a -> b) -> f a -> f b imap = imapDefault {-# INLINE imap #-}-#endif imapDefault :: TraversableWithIndex i f => (i -> a -> b) -> f a -> f b -- imapDefault f = runIdentity #. itraverse (\i a -> Identity (f i a))@@ -117,11 +97,9 @@ -- @ ifoldMap :: Monoid m => (i -> a -> m) -> f a -> m -#if __GLASGOW_HASKELL__ >= 704 default ifoldMap :: (TraversableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m ifoldMap = ifoldMapDefault {-# INLINE ifoldMap #-}-#endif -- | A variant of 'ifoldMap' that is strict in the accumulator. --@@ -260,11 +238,9 @@ -- @ itraverse :: Applicative f => (i -> a -> f b) -> t a -> f (t b) -#if __GLASGOW_HASKELL__ >= 704 default itraverse :: (i ~ Int, Applicative f) => (i -> a -> f b) -> t a -> f (t b) itraverse f s = snd $ runIndexing (traverse (\a -> Indexing (\i -> i `seq` (i + 1, f i a))) s) 0 {-# INLINE itraverse #-}-#endif ------------------------------------------------------------------------------- -- base@@ -541,24 +517,14 @@ imap = Seq.mapWithIndex {-# INLINE imap #-} instance FoldableWithIndex Int Seq where-#if MIN_VERSION_containers(0,5,8) ifoldMap = Seq.foldMapWithIndex-#else- ifoldMap f = Data.Foldable.fold . Seq.mapWithIndex f-#endif {-# INLINE ifoldMap #-} ifoldr = Seq.foldrWithIndex {-# INLINE ifoldr #-} ifoldl f = Seq.foldlWithIndex (flip f) {-# INLINE ifoldl #-} instance TraversableWithIndex Int Seq where-#if MIN_VERSION_containers(0,6,0) itraverse = Seq.traverseWithIndex-#else- -- Much faster than Seq.traverseWithIndex for containers < 0.6.0, see- -- https://github.com/haskell/containers/issues/603.- itraverse f = sequenceA . Seq.mapWithIndex f-#endif {-# INLINE itraverse #-} instance FunctorWithIndex Int IntMap where@@ -566,25 +532,15 @@ {-# INLINE imap #-} instance FoldableWithIndex Int IntMap where-#if MIN_VERSION_containers(0,5,4) ifoldMap = IntMap.foldMapWithKey-#else- ifoldMap = ifoldMapDefault-#endif {-# INLINE ifoldMap #-}-#if MIN_VERSION_containers(0,5,0) ifoldr = IntMap.foldrWithKey ifoldl' = IntMap.foldlWithKey' . flip {-# INLINE ifoldr #-} {-# INLINE ifoldl' #-}-#endif instance TraversableWithIndex Int IntMap where-#if MIN_VERSION_containers(0,5,0) itraverse = IntMap.traverseWithKey-#else- itraverse f = sequenceA . IntMap.mapWithKey f-#endif {-# INLINE itraverse #-} instance FunctorWithIndex k (Map k) where@@ -592,25 +548,15 @@ {-# INLINE imap #-} instance FoldableWithIndex k (Map k) where-#if MIN_VERSION_containers(0,5,4) ifoldMap = Map.foldMapWithKey-#else- ifoldMap = ifoldMapDefault-#endif {-# INLINE ifoldMap #-}-#if MIN_VERSION_containers(0,5,0) ifoldr = Map.foldrWithKey ifoldl' = Map.foldlWithKey' . flip {-# INLINE ifoldr #-} {-# INLINE ifoldl' #-}-#endif instance TraversableWithIndex k (Map k) where-#if MIN_VERSION_containers(0,5,0) itraverse = Map.traverseWithKey-#else- itraverse f = sequenceA . Map.mapWithKey f-#endif {-# INLINE itraverse #-} -------------------------------------------------------------------------------@@ -783,12 +729,11 @@ (j, ff) -> case ma j of ~(k, fa) -> (k, ff <*> fa) {-# INLINE (<*>) #-}-#if __GLASGOW_HASKELL__ >=821+ liftA2 f (Indexing ma) (Indexing mb) = Indexing $ \ i -> case ma i of (j, ja) -> case mb j of ~(k, kb) -> (k, liftA2 f ja kb) {-# INLINE liftA2 #-}-#endif ------------------------------------------------------------------------------- -- Strict curry