semialign-optics 1.1 → 1.2
raw patch · 3 files changed
+25/−162 lines, 3 filesdep +optics-coredep −containersdep −hashabledep −optics-extradep ~basedep ~semialign
Dependencies added: optics-core
Dependencies removed: containers, hashable, optics-extra, these, transformers, transformers-compat, unordered-containers, vector
Dependency ranges changed: base, semialign
Files
- CHANGELOG.md +5/−0
- semialign-optics.cabal +20/−49
- src/Data/Semialign/Indexed.hs +0/−113
CHANGELOG.md view
@@ -1,3 +1,8 @@+# 1.2++- Deprecated in favor of `semialign-1.2`+ Indexed classes use `FunctorWithIndex` from `indexed-traversable` + # 1.1 Initial release
semialign-optics.cabal view
@@ -1,8 +1,8 @@-cabal-version: >=1.10+cabal-version: 1.22 name: semialign-optics-version: 1.1+version: 1.2 synopsis: SemialignWithIndex, i.e. izipWith and ialignWith-homepage: https://github.com/isomorphism/these+homepage: https://github.com/haskellari/these license: BSD3 license-file: LICENSE author: C. McCann, Oleg Grenrus@@ -11,57 +11,28 @@ build-type: Simple extra-source-files: CHANGELOG.md description:- This package provides @SemialignWithIndex@ with two members- .- @- class (FunctorWithIndex i f, Semialign f) => SemialignWithIndex i f | f -> i where- \ ialignWith :: (i -> These a b -> c) -> f a -> f b -> f c- @- .- @- class (SemialignWithIndex i f, Zip f) => ZipWithIndex i f | f -> i where- \ izipWith :: (i -> a -> b -> c) -> f a -> f b -> f c- @- .- Superclass @FunctorWithIndex@ is from @optics-extra@ package.- See https://hackage.haskell.org/package/semialign-indexed for @lens@ variant.+ This package is deprecated.+ It simply re-exports [semialign](https://hackage.haskell.org/package/semialign)+ (and adds a @optics-core@ constraint). tested-with:- GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.1+ GHC ==8.2.2+ || ==8.4.4+ || ==8.6.5+ || ==8.8.4+ || ==8.10.4+ || ==9.0.1 , GHCJS ==8.4 source-repository head type: git- location: https://github.com/isomorphism/these.git+ location: https://github.com/haskellari/these.git+ subdir: semialign-optics library- default-language: Haskell2010- ghc-options: -Wall-- if impl(ghc >=8.0)- ghc-options: -Wno-trustworthy-safe-- hs-source-dirs: src- exposed-modules: Data.Semialign.Indexed-- -- ghc boot libs- build-depends:- base >=4.5.1.0 && <4.14- , containers >=0.4.2.1 && <0.7-- build-depends:- semialign >=1.1 && <1.2- , these >=1 && <1.1-- -- other dependencies- build-depends:- hashable >=1.2.7.0 && <1.4- , optics-extra >=0.2 && <0.3- , unordered-containers >=0.2.8.0 && <0.3- , vector >=0.12.0.2 && <0.13-- -- base shims- if !impl(ghc >=8.0)- build-depends:- transformers >=0.3.0.0 && <0.6- , transformers-compat >=0.6.5 && <0.7+ default-language: Haskell2010+ ghc-options: -Wall+ reexported-modules: Data.Semialign.Indexed+ build-depends: base >=4.10.0.0 && <4.16+ build-depends: semialign >=1.2 && <1.2.1+ build-depends: optics-core ==0.4.*
− src/Data/Semialign/Indexed.hs
@@ -1,113 +0,0 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE Trustworthy #-}-{-# LANGUAGE UndecidableInstances #-}--- | Zipping and aligning of indexed functors.-module Data.Semialign.Indexed (- SemialignWithIndex (..),- ZipWithIndex (..),- ) where--import Prelude hiding (repeat, zip, zipWith)--import Optics.Indexed (FunctorWithIndex (imap))--import Data.Align-import Data.These-import Data.Zip---- Instances-import Control.Applicative (ZipList)-import Data.Functor.Compose (Compose (..))-import Data.Functor.Identity (Identity)-import Data.Functor.Product (Product (..))-import Data.Hashable (Hashable)-import Data.HashMap.Strict (HashMap)-import Data.IntMap (IntMap)-import Data.Map (Map)-import Data.Sequence (Seq)-import Data.Vector (Vector)--import qualified Data.HashMap.Lazy as HM-import qualified Data.IntMap as IntMap-import qualified Data.Map as Map-import qualified Data.Vector as V---- | Indexed version of 'Semialign'.-class (FunctorWithIndex i f, Semialign f) => SemialignWithIndex i f | f -> i where- -- | Analogous to 'alignWith', but also provides an index.- ialignWith :: (i -> These a b -> c) -> f a -> f b -> f c- ialignWith f a b = imap f (align a b)---- | Indexed version of 'Zip'-class (SemialignWithIndex i f, Zip f) => ZipWithIndex i f | f -> i where- -- | Analogous to 'zipWith', but also provides an index.- izipWith :: (i -> a -> b -> c) -> f a -> f b -> f c- izipWith f a b = imap (uncurry . f) (zip a b)------------------------------------------------------------------------------------ base----------------------------------------------------------------------------------instance SemialignWithIndex () Maybe-instance ZipWithIndex () Maybe-instance SemialignWithIndex Int []-instance ZipWithIndex Int []-instance SemialignWithIndex Int ZipList-instance ZipWithIndex Int ZipList------------------------------------------------------------------------------------ transformers----------------------------------------------------------------------------------instance SemialignWithIndex () Identity-instance ZipWithIndex () Identity--instance (SemialignWithIndex i f, SemialignWithIndex j g) => SemialignWithIndex (Either i j) (Product f g) where- ialignWith f (Pair fa ga) (Pair fb gb) = Pair fc gc where- fc = ialignWith (f . Left) fa fb- gc = ialignWith (f . Right) ga gb--instance (ZipWithIndex i f, ZipWithIndex j g) => ZipWithIndex (Either i j) (Product f g) where- izipWith f (Pair fa ga) (Pair fb gb) = Pair fc gc where- fc = izipWith (f . Left) fa fb- gc = izipWith (f . Right) ga gb--instance (SemialignWithIndex i f, SemialignWithIndex j g) => SemialignWithIndex (i, j) (Compose f g) where- ialignWith f (Compose fga) (Compose fgb) = Compose $ ialignWith g fga fgb where- g i (This ga) = imap (\j -> f (i, j) . This) ga- g i (That gb) = imap (\j -> f (i, j) . That) gb- g i (These ga gb) = ialignWith (\j -> f (i, j)) ga gb--instance (ZipWithIndex i f, ZipWithIndex j g) => ZipWithIndex (i, j) (Compose f g) where- izipWith f (Compose fga) (Compose fgb) = Compose fgc where- fgc = izipWith (\i -> izipWith (\j -> f (i, j))) fga fgb------------------------------------------------------------------------------------ containers----------------------------------------------------------------------------------instance SemialignWithIndex Int Seq-instance ZipWithIndex Int Seq-instance SemialignWithIndex Int IntMap-instance ZipWithIndex Int IntMap where- izipWith = IntMap.intersectionWithKey-instance Ord k => SemialignWithIndex k (Map k) where-instance Ord k => ZipWithIndex k (Map k) where- izipWith = Map.intersectionWithKey------------------------------------------------------------------------------------ unordered-containers----------------------------------------------------------------------------------instance (Eq k, Hashable k) => SemialignWithIndex k (HashMap k) where-instance (Eq k, Hashable k) => ZipWithIndex k (HashMap k) where- izipWith = HM.intersectionWithKey------------------------------------------------------------------------------------ vector----------------------------------------------------------------------------------instance SemialignWithIndex Int Vector where-instance ZipWithIndex Int Vector where- izipWith = V.izipWith