semialign 1.3 → 1.3.1
raw patch · 5 files changed
+30/−126 lines, 5 filesdep −bifunctor-classes-compatdep −ghc-primdep −semigroupsdep ~basedep ~containersdep ~hashable
Dependencies removed: bifunctor-classes-compat, ghc-prim, semigroups, transformers-compat, void
Dependency ranges changed: base, containers, hashable, indexed-traversable, indexed-traversable-instances, semigroupoids, tagged, these, transformers, vector
Files
- CHANGELOG.md +4/−0
- semialign.cabal +21/−49
- src/Data/Crosswalk.hs +0/−6
- src/Data/Semialign/Internal.hs +5/−69
- src/Data/Zip.hs +0/−2
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 1.3.1++- Support GHC-8.6.5...GHC-9.10.1+ # 1.3 - Depend on `bifunctor-classes-compat` instead of `bifunctors`
semialign.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: semialign-version: 1.3+version: 1.3.1 synopsis: Align and Zip type-classes from the common Semialign ancestor. @@ -21,21 +21,15 @@ forming lattice-like structure. tested-with:- GHC ==7.4.2- || ==7.6.3- || ==7.8.4- || ==7.10.3- || ==8.0.2- || ==8.2.2- || ==8.4.4- || ==8.6.5- || ==8.8.4- || ==8.10.7- || ==9.0.2- || ==9.2.7- || ==9.4.4- || ==9.6.1- , GHCJS ==8.4+ GHC ==8.6.5+ || ==8.8.4+ || ==8.10.7+ || ==9.0.2+ || ==9.2.8+ || ==9.4.8+ || ==9.6.5+ || ==9.8.2+ || ==9.10.1 source-repository head type: git@@ -49,10 +43,8 @@ library default-language: Haskell2010- ghc-options: -Wall+ ghc-options: -Wall -Wno-trustworthy-safe - if impl(ghc >=8.0)- ghc-options: -Wno-trustworthy-safe if impl(ghc >=9.2) ghc-options: -Wno-noncanonical-monoid-instances @@ -68,41 +60,21 @@ -- ghc boot libs build-depends:- base >=4.5.1.0 && <4.19- , containers >=0.4.2.1 && <0.7- , transformers >=0.3.0.0 && <0.7+ base >=4.12.0.0 && <4.21+ , containers >=0.6.0.1 && <0.8+ , transformers >=0.5.6.2 && <0.7 -- These- build-depends: these >=1.2 && <1.3+ build-depends: these >=1.2.1 && <1.3 -- other dependencies build-depends:- hashable >=1.2.7.0 && <1.5- , indexed-traversable >=0.1.1 && <0.2- , indexed-traversable-instances >=0.1 && <0.2- , tagged >=0.8.6 && <0.9+ hashable >=1.4.4.0 && <1.5+ , indexed-traversable >=0.1.4 && <0.2+ , indexed-traversable-instances >=0.1.2 && <0.2+ , tagged >=0.8.8 && <0.9 , unordered-containers >=0.2.8.0 && <0.3- , vector >=0.12.0.2 && <0.14-- -- base shims- if !impl(ghc >=8.2)- build-depends: bifunctor-classes-compat >=0.1 && <0.2-- if !impl(ghc >=8.0)- build-depends:- semigroups >=0.18.5 && <0.21- , transformers >=0.3.0.0 && <0.7- , transformers-compat >=0.6.5 && <0.8-- -- Ensure Data.Functor.Classes is always available- if impl(ghc >=7.10)- build-depends: transformers >=0.4.2.0-- if !impl(ghc >=7.10)- build-depends: void >=0.7.3 && <0.8-- if impl(ghc <7.5)- build-depends: ghc-prim+ , vector >=0.13.0.0 && <0.14 if flag(semigroupoids)- build-depends: semigroupoids >=5.3.2 && <6.1+ build-depends: semigroupoids >=6.0.1 && <6.1
src/Data/Crosswalk.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE Trustworthy #-} module Data.Crosswalk ( -- * Crosswalk@@ -42,9 +41,7 @@ sequenceL :: (Align f) => t (f a) -> f (t a) sequenceL = crosswalk id -#if __GLASGOW_HASKELL__ >= 707 {-# MINIMAL crosswalk | sequenceL #-}-#endif instance Crosswalk Identity where crosswalk f (Identity a) = fmap Identity (f a)@@ -106,10 +103,7 @@ bisequenceL :: (Align f) => t (f a) (f b) -> f (t a b) bisequenceL = bicrosswalk id id -#if __GLASGOW_HASKELL__ >= 707 {-# MINIMAL bicrosswalk | bisequenceL #-}-#endif- instance Bicrosswalk Either where bicrosswalk f _ (Left x) = Left <$> f x
src/Data/Semialign/Internal.hs view
@@ -2,18 +2,16 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE PolyKinds #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE Trustworthy #-} {-# LANGUAGE UndecidableInstances #-}-#if __GLASGOW_HASKELL__ >= 706-{-# LANGUAGE PolyKinds #-}-#endif module Data.Semialign.Internal where import Prelude (Bool (..), Either (..), Eq (..), Functor (fmap), Int, Maybe (..),- Monad (..), Ord (..), Ordering (..), String, error, flip, fst, id,- maybe, snd, uncurry, ($), (++), (.))+ Monad (..), Ord (..), Ordering (..), String, error, flip, fst, id, maybe,+ snd, uncurry, ($), (++), (.)) import qualified Prelude as Prelude @@ -45,38 +43,22 @@ import qualified Data.Vector as V import qualified Data.Vector.Fusion.Stream.Monadic as Stream -#if MIN_VERSION_vector(0,11,0) import Data.Vector.Fusion.Bundle.Monadic (Bundle (..)) import qualified Data.Vector.Fusion.Bundle.Monadic as Bundle import qualified Data.Vector.Fusion.Bundle.Size as Bundle-#else-import qualified Data.Vector.Fusion.Stream.Size as Stream-#endif -#if MIN_VERSION_containers(0,5,0) import Data.Map.Lazy (Map) import qualified Data.Map.Lazy as Map import Data.IntMap.Lazy (IntMap) import qualified Data.IntMap.Lazy as IntMap -#if MIN_VERSION_containers(0,5,9) import qualified Data.IntMap.Merge.Lazy as IntMap import qualified Data.Map.Merge.Lazy as Map-#endif --- containers <0.5-#else-import Data.Map (Map)-import qualified Data.Map as Map--import Data.IntMap (IntMap)-import qualified Data.IntMap as IntMap-#endif- #if !(MIN_VERSION_base(4,16,0)) import Data.Semigroup (Option (..))-#endif +#endif import Data.These import Data.These.Combinators@@ -95,7 +77,7 @@ -- The laws of 'align' and 'zip' resemble lattice laws. -- There is a plenty of laws, but they are simply satisfied. ----- And an addition property if @f@ is 'Foldable',+-- And an additional property if @f@ is 'Foldable', -- which tries to enforce 'align'-feel: -- neither values are duplicated nor lost. --@@ -139,16 +121,6 @@ -- ≡ mapMaybe justHere (toList (align x y)) -- @ -------- And an addition property if @f@ is 'Foldable',--- which tries to enforce 'align'-feel:--- neither values are duplicated nor lost.------ @--- toList x = toListOf (folded . here) (align x y)--- = mapMaybe justHere (toList (align x y))--- @--- class Functor f => Semialign f where -- | Analogous to @'zip'@, combines two structures by taking the union of -- their shapes and using @'These'@ to hold the elements.@@ -160,9 +132,7 @@ alignWith :: (These a b -> c) -> f a -> f b -> f c alignWith f a b = f <$> align a b -#if __GLASGOW_HASKELL__ >= 707 {-# MINIMAL (align | alignWith) #-}-#endif -- | A unit of 'align'. --@@ -206,11 +176,8 @@ unalignWith :: (c -> These a b) -> f c -> (f a, f b) unalignWith f fx = unalign (fmap f fx) -#if __GLASGOW_HASKELL__ >= 707 {-# MINIMAL unalignWith | unalign #-}-#endif - -- | Functors supporting a 'zip' operation that takes the intersection of -- non-uniform shapes. --@@ -294,9 +261,7 @@ zipWith :: (a -> b -> c) -> f a -> f b -> f c zipWith f a b = uncurry f <$> zip a b -#if __GLASGOW_HASKELL__ >= 707 {-# MINIMAL (zip | zipWith) #-}-#endif -- | Zippable functors supporting left and right units --@@ -337,9 +302,7 @@ unzip :: f (a, b) -> (f a, f b) unzip = unzipWith id -#if __GLASGOW_HASKELL__ >= 707 {-# MINIMAL unzipWith | unzip #-}-#endif unzipDefault :: Functor f => f (a, b) -> (f a, f b) unzipDefault x = (fst <$> x, snd <$> x)@@ -529,12 +492,8 @@ nil = Seq.empty instance Unzip Seq where-#if MIN_VERSION_containers(0,5,11) unzip = Seq.unzip unzipWith = Seq.unzipWith-#else- unzip = unzipDefault-#endif instance Zip Seq where zip = Seq.zip@@ -563,17 +522,9 @@ ------------------------------------------------------------------------------- instance Ord k => Semialign (Map k) where-#if MIN_VERSION_containers(0,5,9) alignWith f = Map.merge (Map.mapMissing (\_ x -> f (This x))) (Map.mapMissing (\_ y -> f (That y))) (Map.zipWithMatched (\_ x y -> f (These x y)))-#elif MIN_VERSION_containers(0,5,0)- alignWith f = Map.mergeWithKey (\_ x y -> Just $ f $ These x y) (fmap (f . This)) (fmap (f . That))-#else- align m n = Map.unionWith merge (Map.map This m) (Map.map That n)- where merge (This a) (That b) = These a b- merge _ _ = oops "Align Map: merge"-#endif instance (Ord k) => Align (Map k) where nil = Map.empty@@ -587,17 +538,9 @@ zipWith = Map.intersectionWith instance Semialign IntMap where-#if MIN_VERSION_containers(0,5,9) alignWith f = IntMap.merge (IntMap.mapMissing (\_ x -> f (This x))) (IntMap.mapMissing (\_ y -> f (That y))) (IntMap.zipWithMatched (\_ x y -> f (These x y)))-#elif MIN_VERSION_containers(0,5,0)- alignWith f = IntMap.mergeWithKey (\_ x y -> Just $ f $ These x y) (fmap (f . This)) (fmap (f . That))-#else- align m n = IntMap.unionWith merge (IntMap.map This m) (IntMap.map That n)- where merge (This a) (That b) = These a b- merge _ _ = oops "Align IntMap: merge"-#endif instance Align IntMap where nil = IntMap.empty@@ -722,13 +665,8 @@ nil = Stream.empty instance Monad m => Semialign (Stream m) where-#if MIN_VERSION_vector(0,11,0) alignWith f (Stream stepa ta) (Stream stepb tb) = Stream step (ta, tb, Nothing, False)-#else- alignWith f (Stream stepa ta na) (Stream stepb tb nb)- = Stream step (ta, tb, Nothing, False) (Stream.larger na nb)-#endif where step (sa, sb, Nothing, False) = do r <- stepa sa@@ -753,14 +691,12 @@ instance Monad m => Zip (Stream m) where zipWith = Stream.zipWith -#if MIN_VERSION_vector(0,11,0) instance Monad m => Align (Bundle m v) where nil = Bundle.empty instance Monad m => Semialign (Bundle m v) where alignWith f Bundle{sElems = sa, sSize = na} Bundle{sElems = sb, sSize = nb} = Bundle.fromStream (alignWith f sa sb) (Bundle.larger na nb)-#endif instance Monad m => Zip (Bundle m v) where zipWith = Bundle.zipWith
src/Data/Zip.hs view
@@ -50,6 +50,4 @@ Zippy f <*> Zippy x = Zippy $ zipWith ($) f x #endif -#if MIN_VERSION_base(4,10,0) liftA2 f (Zippy x) (Zippy y) = Zippy $ zipWith f x y-#endif