on a9a9af4 help sign in
ChangeLog.md+18
since splitsnapshots
unifiedsplit
@@ -1,5 +1,23 @@
1# Revision history for patch
1# Revision history for patch
2
2
3+## Unreleased
4+
5+* Remove the `split-these` flag.
6+ We do not need it as we only use the `These` datatype which is provided in all versions.
7+
8+* Stop defining `Group`; `Group` from the `groups` package can be used instead.
9+
10+ Most of the instances are provided by `groups`, except the `Group
11+ MonoidalMap` instance, which is not lawful. `reflex` might provide it as an
12+ orphan for backwards compat, temporarily, but it should eventually be removed
13+ everywhere.
14+
15+* `Applicative` is still defined, because the `Abelian` from `groups` has too
16+ stringent a constraint.
17+
18+* `Additive` now lives in `Data.Semigroup.Additive`, but is still reexported
19+ from `Data.Patch` for compatability.
20+
3## 0.0.4.0
21## 0.0.4.0
4
22
5* Enable PolyKinds
23* Enable PolyKinds
dep/reflex-platform/default.nix+1−7
@@ -1,8 +1,2 @@
1# DO NOT HAND-EDIT THIS FILE
1# DO NOT HAND-EDIT THIS FILE
2−let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
2+import (import ./thunk.nix)
3− if !fetchSubmodules && !private then builtins.fetchTarball {
4− url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
5− } else (import <nixpkgs> {}).fetchFromGitHub {
6− inherit owner repo rev sha256 fetchSubmodules private;
7− };
8−in import (fetch (builtins.fromJSON (builtins.readFile ./github.json)))
dep/reflex-platform/github.json+2−2
@@ -3,6 +3,6 @@
3 "repo": "reflex-platform",
3 "repo": "reflex-platform",
4 "branch": "master",
4 "branch": "master",
5 "private": false,
5 "private": false,
6− "rev": "c9d11db1b98855fe8ab24a3ff6a5dbe0ad902ad9",
6+ "rev": "efc6d923c633207d18bd4d8cae3e20110a377864",
7− "sha256": "0sfzkqdvyah5mwvmli0wq1nl0b8cvk2cmfgfy4rz57wv42x3099y"
7+ "sha256": "121rmnkx8nwiy96ipfyyv6vrgysv0zpr2br46y70zf4d0y1h1lz5"
8}
8}
dep/reflex-platform/thunk.nixnew file+9
@@ -0,0 +1,9 @@
1+# DO NOT HAND-EDIT THIS FILE
2+let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
3+ if !fetchSubmodules && !private then builtins.fetchTarball {
4+ url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
5+ } else (import <nixpkgs> {}).fetchFromGitHub {
6+ inherit owner repo rev sha256 fetchSubmodules private;
7+ };
8+ json = builtins.fromJSON (builtins.readFile ./github.json);
9+in fetch json
patch.cabal+6−14
@@ -1,5 +1,5 @@
1Name: patch
1Name: patch
2−Version: 0.0.4.0
2+Version: 0.1.0.0
3Synopsis: Data structures for describing changes to other data structures.
3Synopsis: Data structures for describing changes to other data structures.
4Description:
4Description:
5 Data structures for describing changes to other data structures.
5 Data structures for describing changes to other data structures.
@@ -25,11 +25,6 @@ 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.1
26 GHCJS ==8.4
26 GHCJS ==8.4
27
27
28−flag split-these
29− description: Use split these/semialign packages
30− manual: False
31− default: True
32−
33library
28library
34 hs-source-dirs: src
29 hs-source-dirs: src
35 default-language: Haskell2010
30 default-language: Haskell2010
@@ -40,9 +35,13 @@ library
40 , dependent-sum >= 0.6 && < 0.8
35 , dependent-sum >= 0.6 && < 0.8
41 , lens >= 4.7 && < 5
36 , lens >= 4.7 && < 5
42 , semigroupoids >= 4.0 && < 6
37 , semigroupoids >= 4.0 && < 6
38+ , these >= 0.4 && < 1.2
43 , transformers >= 0.5.6.0 && < 0.6
39 , transformers >= 0.5.6.0 && < 0.6
44 , witherable >= 0.3 && < 0.4
40 , witherable >= 0.3 && < 0.4
45
41
42+ if impl(ghc < 8.6) -- really, if base < 8.12
43+ build-depends: base-orphans >= 0.8 && < 0.9
44+
46 exposed-modules: Data.Functor.Misc
45 exposed-modules: Data.Functor.Misc
47 , Data.Monoid.DecidablyEmpty
46 , Data.Monoid.DecidablyEmpty
48 , Data.Patch
47 , Data.Patch
@@ -53,18 +52,11 @@ library
53 , Data.Patch.Map
52 , Data.Patch.Map
54 , Data.Patch.MapWithMove
53 , Data.Patch.MapWithMove
55 , Data.Patch.MapWithPatchingMove
54 , Data.Patch.MapWithPatchingMove
55+ , Data.Semigroup.Additive
56
56
57 ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs
57 ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs
58 default-extensions: PolyKinds
58 default-extensions: PolyKinds
59
59
60− if flag(split-these)
61− build-depends: these >= 1 && <1.2
62− , semialign >=1 && <1.2
63− , monoidal-containers >= 0.6 && < 0.7
64− else
65− build-depends: these >= 0.4 && <0.9
66− , monoidal-containers == 0.4.0.0
67−
68test-suite hlint
60test-suite hlint
69 default-language: Haskell2010
61 default-language: Haskell2010
70 type: exitcode-stdio-1.0
62 type: exitcode-stdio-1.0
src/Data/Patch.hs+2−68
@@ -1,8 +1,6 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3−{-# LANGUAGE StandaloneDeriving #-}
4−{-# LANGUAGE TypeFamilies #-}
5{-# LANGUAGE TypeOperators #-}
2{-# LANGUAGE TypeOperators #-}
3+{-# LANGUAGE TypeFamilies #-}
6-- |
4-- |
7-- Module:
5-- Module:
8-- Data.Patch
6-- Data.Patch
@@ -13,16 +11,11 @@ module Data.Patch
13 , module X
11 , module X
14 ) where
12 ) where
15
13
16−import Control.Applicative
17−import Data.Functor.Const (Const (..))
18−import Data.Functor.Identity
19−import Data.Map.Monoidal (MonoidalMap)
20−import Data.Proxy
21#if !MIN_VERSION_base(4,11,0)
14#if !MIN_VERSION_base(4,11,0)
22import Data.Semigroup (Semigroup (..))
15import Data.Semigroup (Semigroup (..))
23#endif
16#endif
24−import GHC.Generics
25
17
18+import Data.Semigroup.Additive as X
26import Data.Patch.Class as X
19import Data.Patch.Class as X
27import Data.Patch.DMap as X hiding (getDeletions)
20import Data.Patch.DMap as X hiding (getDeletions)
28import Data.Patch.DMapWithMove as X
21import Data.Patch.DMapWithMove as X
@@ -39,68 +32,9 @@ import Data.Patch.MapWithMove as X
39 , unsafePatchMapWithMove
32 , unsafePatchMapWithMove
40 )
33 )
41
34
42−-- | A 'Group' is a 'Monoid' where every element has an inverse.
43−class (Semigroup q, Monoid q) => Group q where
44− negateG :: q -> q
45− (~~) :: q -> q -> q
46− r ~~ s = r <> negateG s
47−
48−-- | An 'Additive' 'Semigroup' is one where (<>) is commutative
49−class Semigroup q => Additive q where
50−
51-- | The elements of an 'Additive' 'Semigroup' can be considered as patches of their own type.
35-- | The elements of an 'Additive' 'Semigroup' can be considered as patches of their own type.
52newtype AdditivePatch p = AdditivePatch { unAdditivePatch :: p }
36newtype AdditivePatch p = AdditivePatch { unAdditivePatch :: p }
53
37
54instance Additive p => Patch (AdditivePatch p) where
38instance Additive p => Patch (AdditivePatch p) where
55 type PatchTarget (AdditivePatch p) = p
39 type PatchTarget (AdditivePatch p) = p
56 apply (AdditivePatch p) q = Just $ p <> q
40 apply (AdditivePatch p) q = Just $ p <> q
57−
58−instance (Ord k, Group q) => Group (MonoidalMap k q) where
59− negateG = fmap negateG
60−
61−instance (Ord k, Additive q) => Additive (MonoidalMap k q)
62−
63−-- | Trivial group.
64−instance Group () where
65− negateG _ = ()
66− _ ~~ _ = ()
67−instance Additive ()
68−
69−-- | Product group. A Pair of groups gives rise to a group
70−instance (Group a, Group b) => Group (a, b) where
71− negateG (a, b) = (negateG a, negateG b)
72− (a, b) ~~ (c, d) = (a ~~ c, b ~~ d)
73−instance (Additive a, Additive b) => Additive (a, b)
74−
75−-- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided.
76−-- Base does not define Monoid (Compose f g a) so this is the best we can
77−-- really do for functor composition.
78−instance Group (f (g a)) => Group ((f :.: g) a) where
79− negateG (Comp1 xs) = Comp1 (negateG xs)
80− Comp1 xs ~~ Comp1 ys = Comp1 (xs ~~ ys)
81−instance Additive (f (g a)) => Additive ((f :.: g) a)
82−
83−-- | Product of groups, Functor style.
84−instance (Group (f a), Group (g a)) => Group ((f :*: g) a) where
85− negateG (a :*: b) = negateG a :*: negateG b
86− (a :*: b) ~~ (c :*: d) = (a ~~ c) :*: (b ~~ d)
87−instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a)
88−
89−-- | Trivial group, Functor style
90−instance Group (Proxy x) where
91− negateG _ = Proxy
92− _ ~~ _ = Proxy
93−instance Additive (Proxy x)
94−
95−-- | Const lifts groups into a functor.
96−deriving instance Group a => Group (Const a x)
97−instance Additive a => Additive (Const a x)
98−-- | Ideitnty lifts groups pointwise (at only one point)
99−deriving instance Group a => Group (Identity a)
100−instance Additive a => Additive (Identity a)
101−
102−-- | Functions lift groups pointwise.
103−instance Group b => Group (a -> b) where
104− negateG f = negateG . f
105− (~~) = liftA2 (~~)
106−instance Additive b => Additive (a -> b)
src/Data/Semigroup/Additive.hsnew file+52
@@ -0,0 +1,52 @@
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE TypeOperators #-}
3+{-# LANGUAGE TypeFamilies #-}
4+-- |
5+-- Module:
6+-- Data.Semigroup.Additive
7+-- Description:
8+-- This module defines a class for commutative semigroups, until it is moved
9+-- to another library.
10+module Data.Semigroup.Additive
11+ ( Additive
12+ ) where
13+
14+import Data.Functor.Const (Const (..))
15+import Data.Functor.Identity
16+import Data.Proxy
17+#if !MIN_VERSION_base(4,12,0)
18+-- for :*: and :.: semigroup instances
19+import Data.Orphans ()
20+#endif
21+#if !MIN_VERSION_base(4,11,0)
22+import Data.Semigroup (Semigroup (..))
23+#endif
24+import GHC.Generics
25+
26+-- | An 'Additive' 'Semigroup' is one where (<>) is commutative
27+class Semigroup q => Additive q where
28+
29+-- | Trivial group.
30+instance Additive ()
31+
32+-- | Product group. A Pair of groups gives rise to a group
33+instance (Additive a, Additive b) => Additive (a, b)
34+
35+-- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided.
36+-- Base does not define Monoid (Compose f g a) so this is the best we can
37+-- really do for functor composition.
38+instance Additive (f (g a)) => Additive ((f :.: g) a)
39+
40+-- | Product of groups, Functor style.
41+instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a)
42+
43+-- | Trivial group, Functor style
44+instance Additive (Proxy x)
45+
46+-- | Const lifts groups into a functor.
47+instance Additive a => Additive (Const a x)
48+-- | Ideitnty lifts groups pointwise (at only one point)
49+instance Additive a => Additive (Identity a)
50+
51+-- | Functions lift groups pointwise.
52+instance Additive b => Additive (a -> b)