Skip to content

Commit 15ea495

Browse files
authored
Merge pull request #40 from maralorn/lens-five
Bump bounds
2 parents d943809 + 60c97f2 commit 15ea495

File tree

4 files changed

+41
-16
lines changed

4 files changed

+41
-16
lines changed

patch.cabal

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ flag split-these
3333
library
3434
hs-source-dirs: src
3535
default-language: Haskell2010
36-
build-depends: base >= 4.9 && < 4.15
36+
build-depends: base >= 4.9 && < 4.16
3737
, constraints-extras >= 0.3 && < 0.4
3838
, containers >= 0.6 && < 0.7
3939
, dependent-map >= 0.3 && < 0.5
4040
, dependent-sum >= 0.6 && < 0.8
41-
, lens >= 4.7 && < 5
41+
, lens >= 4.7 && < 5.1
42+
, indexed-traversable >= 0.1 && < 0.2
4243
, semigroupoids >= 4.0 && < 6
4344
, transformers >= 0.5.6.0 && < 0.6
4445
, witherable >= 0.3 && < 0.5
@@ -63,7 +64,7 @@ library
6364

6465
if flag(split-these)
6566
build-depends: these >= 1 && <1.2
66-
, semialign >=1 && <1.2
67+
, semialign >=1 && <1.3
6768
, monoidal-containers >= 0.6 && < 0.7
6869
else
6970
build-depends: these >= 0.4 && <0.9
@@ -91,7 +92,7 @@ test-suite hlint
9192
, directory
9293
, filepath
9394
, filemanip
94-
, hlint (< 2.1 || >= 2.2.2) && < 3.3
95+
, hlint (< 2.1 || >= 2.2.2) && < 3.4
9596
if impl(ghcjs)
9697
buildable: False
9798

src/Data/Patch/IntMap.hs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Patches of this sort allow for insert/update or delete of associations.
1414
-}
1515
module Data.Patch.IntMap where
1616

17-
import Control.Lens
17+
import Control.Lens hiding (FunctorWithIndex, FoldableWithIndex, TraversableWithIndex)
18+
import qualified Control.Lens as L
1819
import Data.IntMap.Strict (IntMap)
1920
import qualified Data.IntMap.Strict as IntMap
2021
import Data.Maybe
@@ -23,6 +24,9 @@ import Data.Monoid.DecidablyEmpty
2324
import Data.Semigroup (Semigroup (..))
2425
#endif
2526
import Data.Patch.Class
27+
import Data.Functor.WithIndex
28+
import Data.Foldable.WithIndex
29+
import Data.Traversable.WithIndex
2630

2731
-- | 'Patch' for 'IntMap' which represents insertion or deletion of keys in the mapping.
2832
-- Internally represented by 'IntMap (Maybe a)', where @Just@ means insert/update
@@ -51,8 +55,13 @@ instance Patch (PatchIntMap a) where
5155
instance FunctorWithIndex Int PatchIntMap
5256
instance FoldableWithIndex Int PatchIntMap
5357
instance TraversableWithIndex Int PatchIntMap where
54-
itraverse = itraversed . Indexed
55-
itraversed = _Wrapped .> itraversed <. traversed
58+
itraverse = (_Wrapped .> itraversed <. traversed) . Indexed
59+
60+
#if !MIN_VERSION_lens(5,0,0)
61+
instance L.FunctorWithIndex Int PatchIntMap where imap = Data.Functor.WithIndex.imap
62+
instance L.FoldableWithIndex Int PatchIntMap where ifoldMap = Data.Foldable.WithIndex.ifoldMap
63+
instance L.TraversableWithIndex Int PatchIntMap where itraverse = Data.Traversable.WithIndex.itraverse
64+
#endif
5665

5766
-- | Map a function @Int -> a -> b@ over all @a@s in the given @'PatchIntMap' a@
5867
-- (that is, all inserts/updates), producing a @PatchIntMap b@.

src/Data/Patch/Map.hs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ module Data.Patch.Map where
1818

1919
import Data.Patch.Class
2020

21-
import Control.Lens
21+
import Control.Lens hiding (FunctorWithIndex, FoldableWithIndex, TraversableWithIndex)
22+
import qualified Control.Lens as L
2223
import Data.Map (Map)
2324
import qualified Data.Map as Map
2425
import Data.Maybe
2526
import Data.Monoid.DecidablyEmpty
2627
import Data.Semigroup (Semigroup (..), stimesIdempotentMonoid)
28+
import Data.Functor.WithIndex
29+
import Data.Foldable.WithIndex
30+
import Data.Traversable.WithIndex
2731

2832
-- | A set of changes to a 'Map'. Any element may be inserted/updated or
2933
-- deleted. Insertions are represented as values wrapped in 'Just', while
@@ -62,8 +66,13 @@ instance Ord k => Patch (PatchMap k v) where
6266
instance FunctorWithIndex k (PatchMap k)
6367
instance FoldableWithIndex k (PatchMap k)
6468
instance TraversableWithIndex k (PatchMap k) where
65-
itraverse = itraversed . Indexed
66-
itraversed = _Wrapped .> itraversed <. traversed
69+
itraverse = (_Wrapped .> itraversed <. traversed) . Indexed
70+
71+
#if !MIN_VERSION_lens(5,0,0)
72+
instance L.FunctorWithIndex k (PatchMap k) where imap = Data.Functor.WithIndex.imap
73+
instance L.FoldableWithIndex k (PatchMap k) where ifoldMap = Data.Foldable.WithIndex.ifoldMap
74+
instance L.TraversableWithIndex k (PatchMap k) where itraverse = Data.Traversable.WithIndex.itraverse
75+
#endif
6776

6877
-- | Returns all the new elements that will be added to the 'Map'
6978
patchMapNewElements :: PatchMap k v -> [v]

src/Data/Patch/MapWithMove.hs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ import Data.Patch.Class
7070
import Data.Patch.MapWithPatchingMove (PatchMapWithPatchingMove(..), To)
7171
import qualified Data.Patch.MapWithPatchingMove as PM -- already a transparent synonym
7272

73-
import Control.Lens
73+
import Control.Lens hiding (FunctorWithIndex, FoldableWithIndex, TraversableWithIndex)
74+
import qualified Control.Lens as L
7475
import Data.List
7576
import Data.Map (Map)
7677
import qualified Data.Map as Map
@@ -79,6 +80,9 @@ import Data.Proxy
7980
import Data.Semigroup (Semigroup (..))
8081
#endif
8182
import Data.Traversable (foldMapDefault)
83+
import Data.Functor.WithIndex
84+
import Data.Foldable.WithIndex
85+
import Data.Traversable.WithIndex
8286

8387
-- | Patch a Map with additions, deletions, and moves. Invariant: If key @k1@
8488
-- is coming from @From_Move k2@, then key @k2@ should be going to @Just k1@,
@@ -133,11 +137,13 @@ instance Traversable (PatchMapWithMove k) where
133137
instance FunctorWithIndex k (PatchMapWithMove k)
134138
instance FoldableWithIndex k (PatchMapWithMove k)
135139
instance TraversableWithIndex k (PatchMapWithMove k) where
136-
itraverse = itraversed . Indexed
137-
itraversed =
138-
_PatchMapWithMove .>
139-
itraversed <.
140-
traverse
140+
itraverse = (_PatchMapWithMove .> itraversed <. traverse) . Indexed
141+
142+
#if !MIN_VERSION_lens(5,0,0)
143+
instance L.FunctorWithIndex k (PatchMapWithMove k) where imap = Data.Functor.WithIndex.imap
144+
instance L.FoldableWithIndex k (PatchMapWithMove k) where ifoldMap = Data.Foldable.WithIndex.ifoldMap
145+
instance L.TraversableWithIndex k (PatchMapWithMove k) where itraverse = Data.Traversable.WithIndex.itraverse
146+
#endif
141147

142148
-- | Create a 'PatchMapWithMove', validating it
143149
patchMapWithMove :: Ord k => Map k (NodeInfo k v) -> Maybe (PatchMapWithMove k v)

0 commit comments

Comments
 (0)