Skip to content

Commit 33ac344

Browse files
committed
Merge branch 'develop' into use-commutative-semigroups
2 parents 7384cf7 + 4e085fa commit 33ac344

File tree

9 files changed

+57
-26
lines changed

9 files changed

+57
-26
lines changed

.github/workflows/haskell.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: github-action
22

3-
on: [push, pull_request]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
77
strategy:
88
matrix:
9-
ghc: ['8.0.2', '8.2.2', '8.4.4', '8.6.5', '8.8.4', '8.10.2']
9+
ghc: ['8.0.2', '8.2.2', '8.4.4', '8.6.5', '8.8.4', '8.10.7', '9.0.1', '9.2.2']
1010
os: ['ubuntu-latest', 'macos-latest']
1111
exclude:
1212
# There are some linker warnings in 802 on darwin that
@@ -19,7 +19,7 @@ jobs:
1919
name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
2020
steps:
2121
- uses: actions/checkout@v2
22-
- uses: actions/setup-haskell@v1
22+
- uses: haskell/actions/setup@v1
2323
with:
2424
ghc-version: ${{ matrix.ghc }}
2525
- name: Cache

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Use `commutative-semigroups` for `Commutative`, making `Additive` a
66
deprecated alias.
77

8+
* Support GHC 9.2
9+
810
## 0.0.5.2 - 2022-01-09
911

1012
* Correct field order of `PatchMapWithMove.NodeInfo`.

patch.cabal

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extra-source-files:
2222
ChangeLog.md
2323

2424
tested-with:
25-
GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.1
25+
GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.1 || ==9.2.2
2626
GHCJS ==8.4
2727

2828
flag split-these
@@ -33,15 +33,16 @@ 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.17
3737
, constraints-extras >= 0.3 && < 0.4
3838
, commutative-semigroups >= 0.0 && < 0.1
3939
, containers >= 0.6 && < 0.7
4040
, dependent-map >= 0.3 && < 0.5
4141
, dependent-sum >= 0.6 && < 0.8
42-
, lens >= 4.7 && < 5
42+
, lens >= 4.7 && < 5.2
43+
, indexed-traversable >= 0.1 && < 0.2
4344
, semigroupoids >= 4.0 && < 6
44-
, transformers >= 0.5.6.0 && < 0.6
45+
, transformers >= 0.5.6.0 && < 0.7
4546
, witherable >= 0.3 && < 0.5
4647

4748
if impl(ghc < 8.6) -- really, if base < 8.12
@@ -64,7 +65,7 @@ library
6465

6566
if flag(split-these)
6667
build-depends: these >= 1 && <1.2
67-
, semialign >=1 && <1.2
68+
, semialign >=1 && <1.3
6869
, monoidal-containers >= 0.6 && < 0.7
6970
else
7071
build-depends: these >= 0.4 && <0.9
@@ -92,7 +93,7 @@ test-suite hlint
9293
, directory
9394
, filepath
9495
, filemanip
95-
, hlint (< 2.1 || >= 2.2.2) && < 3.3
96+
, hlint (< 2.1 || >= 2.2.2) && < 3.5
9697
if impl(ghcjs)
9798
buildable: False
9899

src/Data/Functor/Misc.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import Data.GADT.Compare
5050
import Data.GADT.Show
5151
import Data.IntMap (IntMap)
5252
import qualified Data.IntMap as IntMap
53+
import Data.Kind (Type)
5354
import Data.Map (Map)
5455
import qualified Data.Map as Map
5556
import Data.Some (Some, mkSome)
@@ -63,7 +64,7 @@ import Data.Typeable hiding (Refl)
6364

6465
-- | 'Const2' stores a value of a given type 'k' and ensures that a particular
6566
-- type 'v' is always given for the last type parameter
66-
data Const2 :: * -> x -> x -> * where
67+
data Const2 :: Type -> x -> x -> Type where
6768
Const2 :: k -> Const2 k v v
6869
deriving (Typeable)
6970

@@ -130,7 +131,7 @@ weakenDMapWith f = Map.fromDistinctAscList . map (\(k :=> v) -> (mkSome k, f v))
130131
-- | 'WrapArg' can be used to tag a value in one functor with a type
131132
-- representing another functor. This was primarily used with dependent-map <
132133
-- 0.2, in which the value type was not wrapped in a separate functor.
133-
data WrapArg :: (k -> *) -> (k -> *) -> * -> * where
134+
data WrapArg :: (k -> Type) -> (k -> Type) -> Type -> Type where
134135
WrapArg :: f a -> WrapArg g f (g a)
135136

136137
deriving instance Eq (f a) => Eq (WrapArg g f (g' a))

src/Data/Monoid/DecidablyEmpty.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ instance DecidablyEmpty (First a) where
6969
instance DecidablyEmpty (Last a) where
7070
isEmpty (Last a) = isNothing a
7171
deriving instance DecidablyEmpty a => DecidablyEmpty (Identity a)
72+
#if !MIN_VERSION_base(4,16,0)
7273
instance Semigroup a => DecidablyEmpty (Option a) where
7374
isEmpty (Option a) = isNothing a
75+
#endif
7476
deriving instance DecidablyEmpty m => DecidablyEmpty (WrappedMonoid m)
7577
instance (Ord a, Bounded a) => DecidablyEmpty (Max a)
7678
instance (Ord a, Bounded a) => DecidablyEmpty (Min a)

src/Data/Patch/DMapWithMove.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import Data.Functor.Misc
3333
import Data.Functor.Product
3434
import Data.GADT.Compare (GEq (..), GCompare (..))
3535
import Data.GADT.Show (GShow, gshow)
36+
import Data.Kind (Type)
3637
import qualified Data.Map as Map
3738
import Data.Maybe
3839
import Data.Monoid.DecidablyEmpty
@@ -67,7 +68,7 @@ data NodeInfo k v a = NodeInfo
6768

6869
-- |Structure describing a particular change to a key, be it inserting a new key (@From_Insert@), updating an existing key (@From_Insert@ again), deleting a
6970
-- key (@From_Delete@), or moving a key (@From_Move@).
70-
data From (k :: a -> *) (v :: a -> *) :: a -> * where
71+
data From (k :: a -> Type) (v :: a -> Type) :: a -> Type where
7172
-- |Insert a new or update an existing key with the given value @v a@
7273
From_Insert :: v a -> From k v a
7374
-- |Delete the existing key

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: 14 additions & 5 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
@@ -59,11 +63,18 @@ instance Ord k => Patch (PatchMap k v) where
5963
Nothing -> Just ()
6064
Just _ -> Nothing
6165

66+
makeWrapped ''PatchMap
67+
6268
instance FunctorWithIndex k (PatchMap k)
6369
instance FoldableWithIndex k (PatchMap k)
6470
instance TraversableWithIndex k (PatchMap k) where
65-
itraverse = itraversed . Indexed
66-
itraversed = _Wrapped .> itraversed <. traversed
71+
itraverse = (_Wrapped .> itraversed <. traversed) . Indexed
72+
73+
#if !MIN_VERSION_lens(5,0,0)
74+
instance L.FunctorWithIndex k (PatchMap k) where imap = Data.Functor.WithIndex.imap
75+
instance L.FoldableWithIndex k (PatchMap k) where ifoldMap = Data.Foldable.WithIndex.ifoldMap
76+
instance L.TraversableWithIndex k (PatchMap k) where itraverse = Data.Traversable.WithIndex.itraverse
77+
#endif
6778

6879
-- | Returns all the new elements that will be added to the 'Map'
6980
patchMapNewElements :: PatchMap k v -> [v]
@@ -72,5 +83,3 @@ patchMapNewElements (PatchMap p) = catMaybes $ Map.elems p
7283
-- | Returns all the new elements that will be added to the 'Map'
7384
patchMapNewElementsMap :: PatchMap k v -> Map k v
7485
patchMapNewElementsMap (PatchMap p) = Map.mapMaybe id p
75-
76-
makeWrapped ''PatchMap

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)