From 485c59236f357458d8650bb7433e72a857c57d4c Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 8 Dec 2020 22:10:46 -0500 Subject: [PATCH 1/8] Bump reflex platform --- dep/reflex-platform/default.nix | 8 +------- dep/reflex-platform/github.json | 4 ++-- dep/reflex-platform/thunk.nix | 9 +++++++++ 3 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 dep/reflex-platform/thunk.nix diff --git a/dep/reflex-platform/default.nix b/dep/reflex-platform/default.nix index 0cf822e3..2b4d4ab1 100644 --- a/dep/reflex-platform/default.nix +++ b/dep/reflex-platform/default.nix @@ -1,8 +1,2 @@ # DO NOT HAND-EDIT THIS FILE -let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }: - if !fetchSubmodules && !private then builtins.fetchTarball { - url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256; - } else (import {}).fetchFromGitHub { - inherit owner repo rev sha256 fetchSubmodules private; - }; -in import (fetch (builtins.fromJSON (builtins.readFile ./github.json))) +import (import ./thunk.nix) \ No newline at end of file diff --git a/dep/reflex-platform/github.json b/dep/reflex-platform/github.json index a89e6552..0f355191 100644 --- a/dep/reflex-platform/github.json +++ b/dep/reflex-platform/github.json @@ -3,6 +3,6 @@ "repo": "reflex-platform", "branch": "master", "private": false, - "rev": "c9d11db1b98855fe8ab24a3ff6a5dbe0ad902ad9", - "sha256": "0sfzkqdvyah5mwvmli0wq1nl0b8cvk2cmfgfy4rz57wv42x3099y" + "rev": "efc6d923c633207d18bd4d8cae3e20110a377864", + "sha256": "121rmnkx8nwiy96ipfyyv6vrgysv0zpr2br46y70zf4d0y1h1lz5" } diff --git a/dep/reflex-platform/thunk.nix b/dep/reflex-platform/thunk.nix new file mode 100644 index 00000000..bbf2dc18 --- /dev/null +++ b/dep/reflex-platform/thunk.nix @@ -0,0 +1,9 @@ +# DO NOT HAND-EDIT THIS FILE +let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }: + if !fetchSubmodules && !private then builtins.fetchTarball { + url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256; + } else (import {}).fetchFromGitHub { + inherit owner repo rev sha256 fetchSubmodules private; + }; + json = builtins.fromJSON (builtins.readFile ./github.json); +in fetch json \ No newline at end of file From f6d4c9a6288306e310cc21f7b6b580bcd2c69ed7 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Dec 2020 12:07:39 -0500 Subject: [PATCH 2/8] Delete group class, the groups package should be used instead Keep `Additive`, however. See ChangeLog for more details. The version in the cabal file is bumped to remind whoever does the future release that this is breaking change. Closes #4. --- ChangeLog.md | 15 +++++++++++++++ patch.cabal | 16 ++-------------- src/Data/Patch.hs | 37 +------------------------------------ 3 files changed, 18 insertions(+), 50 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 6223cc06..3e73894c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,20 @@ # Revision history for patch +## Unreleased + +* Remove the `split-these` flag. + We do not need it as we only use the `These` datatype which is provided in all versions. + +* Stop defining `Group`; `Group` from the `groups` package can be used instead. + + Most of the instances are provided by `groups`, except the `Group + MonoidalMap` instance, which is not lawful. `reflex` might provide it as an + orphan for backwards compat, temporarily, but it should eventually be removed + everywhere. + +* `Applicative` is still defined, because the `Abelian` from `groups` has too + stringent a constraint. + ## 0.0.3.2 * Update version bounds diff --git a/patch.cabal b/patch.cabal index 53072e7a..27a41611 100644 --- a/patch.cabal +++ b/patch.cabal @@ -1,5 +1,5 @@ Name: patch -Version: 0.0.3.2 +Version: 0.1.0.0 Synopsis: Data structures for describing changes to other data structures. Description: Data structures for describing changes to other data structures. @@ -25,11 +25,6 @@ tested-with: GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.1 GHCJS ==8.4 -flag split-these - description: Use split these/semialign packages - manual: False - default: True - library hs-source-dirs: src default-language: Haskell2010 @@ -40,6 +35,7 @@ library , dependent-sum >= 0.6 && < 0.8 , lens >= 4.7 && < 5 , semigroupoids >= 4.0 && < 6 + , these >= 0.4 && < 1.2 , transformers >= 0.5.6.0 && < 0.6 , witherable >= 0.3 && < 0.4 @@ -56,14 +52,6 @@ library ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs - if flag(split-these) - build-depends: these >= 1 && <1.2 - , semialign >=1 && <1.2 - , monoidal-containers >= 0.6 && < 0.7 - else - build-depends: these >= 0.4 && <0.9 - , monoidal-containers == 0.4.0.0 - test-suite hlint default-language: Haskell2010 type: exitcode-stdio-1.0 diff --git a/src/Data/Patch.hs b/src/Data/Patch.hs index 7b6eb85e..2b3d22a7 100644 --- a/src/Data/Patch.hs +++ b/src/Data/Patch.hs @@ -1,8 +1,6 @@ {-# LANGUAGE CPP #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} +{-# LANGUAGE TypeFamilies #-} -- | -- Module: -- Data.Patch @@ -13,10 +11,8 @@ module Data.Patch , module X ) where -import Control.Applicative import Data.Functor.Const (Const (..)) import Data.Functor.Identity -import Data.Map.Monoidal (MonoidalMap) import Data.Proxy #if !MIN_VERSION_base(4,11,0) import Data.Semigroup (Semigroup (..)) @@ -39,12 +35,6 @@ import Data.Patch.MapWithMove as X , unsafePatchMapWithMove ) --- | A 'Group' is a 'Monoid' where every element has an inverse. -class (Semigroup q, Monoid q) => Group q where - negateG :: q -> q - (~~) :: q -> q -> q - r ~~ s = r <> negateG s - -- | An 'Additive' 'Semigroup' is one where (<>) is commutative class Semigroup q => Additive q where @@ -55,52 +45,27 @@ instance Additive p => Patch (AdditivePatch p) where type PatchTarget (AdditivePatch p) = p apply (AdditivePatch p) q = Just $ p <> q -instance (Ord k, Group q) => Group (MonoidalMap k q) where - negateG = fmap negateG - -instance (Ord k, Additive q) => Additive (MonoidalMap k q) - -- | Trivial group. -instance Group () where - negateG _ = () - _ ~~ _ = () instance Additive () -- | Product group. A Pair of groups gives rise to a group -instance (Group a, Group b) => Group (a, b) where - negateG (a, b) = (negateG a, negateG b) - (a, b) ~~ (c, d) = (a ~~ c, b ~~ d) instance (Additive a, Additive b) => Additive (a, b) -- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided. -- Base does not define Monoid (Compose f g a) so this is the best we can -- really do for functor composition. -instance Group (f (g a)) => Group ((f :.: g) a) where - negateG (Comp1 xs) = Comp1 (negateG xs) - Comp1 xs ~~ Comp1 ys = Comp1 (xs ~~ ys) instance Additive (f (g a)) => Additive ((f :.: g) a) -- | Product of groups, Functor style. -instance (Group (f a), Group (g a)) => Group ((f :*: g) a) where - negateG (a :*: b) = negateG a :*: negateG b - (a :*: b) ~~ (c :*: d) = (a ~~ c) :*: (b ~~ d) instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a) -- | Trivial group, Functor style -instance Group (Proxy x) where - negateG _ = Proxy - _ ~~ _ = Proxy instance Additive (Proxy x) -- | Const lifts groups into a functor. -deriving instance Group a => Group (Const a x) instance Additive a => Additive (Const a x) -- | Ideitnty lifts groups pointwise (at only one point) -deriving instance Group a => Group (Identity a) instance Additive a => Additive (Identity a) -- | Functions lift groups pointwise. -instance Group b => Group (a -> b) where - negateG f = negateG . f - (~~) = liftA2 (~~) instance Additive b => Additive (a -> b) From 830add423b76b7b838966769f14b212733ac7c23 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 11 Dec 2020 15:00:14 -0500 Subject: [PATCH 3/8] Move `Additive` to its own module --- ChangeLog.md | 3 +++ patch.cabal | 1 + src/Data/Patch.hs | 33 +---------------------- src/Data/Semigroup/Additive.hs | 48 ++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 32 deletions(-) create mode 100644 src/Data/Semigroup/Additive.hs diff --git a/ChangeLog.md b/ChangeLog.md index 3e73894c..56e78ced 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -15,6 +15,9 @@ * `Applicative` is still defined, because the `Abelian` from `groups` has too stringent a constraint. +* `Additive` now lives in `Data.Semigroup.Additive`, but is still reexported + from `Data.Patch` for compatability. + ## 0.0.3.2 * Update version bounds diff --git a/patch.cabal b/patch.cabal index 27a41611..2ac2f05c 100644 --- a/patch.cabal +++ b/patch.cabal @@ -49,6 +49,7 @@ library , Data.Patch.Map , Data.Patch.MapWithMove , Data.Patch.MapWithPatchingMove + , Data.Semigroup.Additive ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs diff --git a/src/Data/Patch.hs b/src/Data/Patch.hs index 2b3d22a7..572f345c 100644 --- a/src/Data/Patch.hs +++ b/src/Data/Patch.hs @@ -11,14 +11,11 @@ module Data.Patch , module X ) where -import Data.Functor.Const (Const (..)) -import Data.Functor.Identity -import Data.Proxy #if !MIN_VERSION_base(4,11,0) import Data.Semigroup (Semigroup (..)) #endif -import GHC.Generics +import Data.Semigroup.Additive as X import Data.Patch.Class as X import Data.Patch.DMap as X hiding (getDeletions) import Data.Patch.DMapWithMove as X @@ -35,37 +32,9 @@ import Data.Patch.MapWithMove as X , unsafePatchMapWithMove ) --- | An 'Additive' 'Semigroup' is one where (<>) is commutative -class Semigroup q => Additive q where - -- | The elements of an 'Additive' 'Semigroup' can be considered as patches of their own type. newtype AdditivePatch p = AdditivePatch { unAdditivePatch :: p } instance Additive p => Patch (AdditivePatch p) where type PatchTarget (AdditivePatch p) = p apply (AdditivePatch p) q = Just $ p <> q - --- | Trivial group. -instance Additive () - --- | Product group. A Pair of groups gives rise to a group -instance (Additive a, Additive b) => Additive (a, b) - --- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided. --- Base does not define Monoid (Compose f g a) so this is the best we can --- really do for functor composition. -instance Additive (f (g a)) => Additive ((f :.: g) a) - --- | Product of groups, Functor style. -instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a) - --- | Trivial group, Functor style -instance Additive (Proxy x) - --- | Const lifts groups into a functor. -instance Additive a => Additive (Const a x) --- | Ideitnty lifts groups pointwise (at only one point) -instance Additive a => Additive (Identity a) - --- | Functions lift groups pointwise. -instance Additive b => Additive (a -> b) diff --git a/src/Data/Semigroup/Additive.hs b/src/Data/Semigroup/Additive.hs new file mode 100644 index 00000000..33c3935e --- /dev/null +++ b/src/Data/Semigroup/Additive.hs @@ -0,0 +1,48 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE TypeFamilies #-} +-- | +-- Module: +-- Data.Semigroup.Additive +-- Description: +-- This module defines a class for commutative semigroups, until it is moved +-- to another library. +module Data.Semigroup.Additive + ( Additive + ) where + +import Data.Functor.Const (Const (..)) +import Data.Functor.Identity +import Data.Proxy +#if !MIN_VERSION_base(4,11,0) +import Data.Semigroup (Semigroup (..)) +#endif +import GHC.Generics + +-- | An 'Additive' 'Semigroup' is one where (<>) is commutative +class Semigroup q => Additive q where + +-- | Trivial group. +instance Additive () + +-- | Product group. A Pair of groups gives rise to a group +instance (Additive a, Additive b) => Additive (a, b) + +-- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided. +-- Base does not define Monoid (Compose f g a) so this is the best we can +-- really do for functor composition. +instance Additive (f (g a)) => Additive ((f :.: g) a) + +-- | Product of groups, Functor style. +instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a) + +-- | Trivial group, Functor style +instance Additive (Proxy x) + +-- | Const lifts groups into a functor. +instance Additive a => Additive (Const a x) +-- | Ideitnty lifts groups pointwise (at only one point) +instance Additive a => Additive (Identity a) + +-- | Functions lift groups pointwise. +instance Additive b => Additive (a -> b) From 57bdb25142a28f05511a9bd3fd565d01372c8b21 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 12 Dec 2020 11:36:59 -0500 Subject: [PATCH 4/8] Fix GHC < 8.6 build It turns out we were relying on instances from a transitive dependency on base-orphans. Added that explicitly so that we don't regress on the instances provided with old GHCs. --- patch.cabal | 3 +++ src/Data/Semigroup/Additive.hs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/patch.cabal b/patch.cabal index 2ac2f05c..8b684b3a 100644 --- a/patch.cabal +++ b/patch.cabal @@ -39,6 +39,9 @@ library , transformers >= 0.5.6.0 && < 0.6 , witherable >= 0.3 && < 0.4 + if impl(ghc < 8.6) -- really, if base < 8.12 + build-depends: base-orphans >= 0.8 && < 0.9 + exposed-modules: Data.Functor.Misc , Data.Monoid.DecidablyEmpty , Data.Patch diff --git a/src/Data/Semigroup/Additive.hs b/src/Data/Semigroup/Additive.hs index 33c3935e..67454431 100644 --- a/src/Data/Semigroup/Additive.hs +++ b/src/Data/Semigroup/Additive.hs @@ -14,6 +14,10 @@ module Data.Semigroup.Additive import Data.Functor.Const (Const (..)) import Data.Functor.Identity import Data.Proxy +#if !MIN_VERSION_base(4,12,0) +-- for :*: and :.: semigroup instances +import Data.Orphans () +#endif #if !MIN_VERSION_base(4,11,0) import Data.Semigroup (Semigroup (..)) #endif From b3a8b00e0423a4f809109baa1a52bab66bacbccf Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 13 Oct 2021 17:19:14 -0400 Subject: [PATCH 5/8] Fix typo in change log --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 92936bdf..35bb5f42 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -12,7 +12,7 @@ orphan for backwards compat, temporarily, but it should eventually be removed everywhere. -* `Applicative` is still defined, because the `Abelian` from `groups` has too +* `Additive` is still defined, because the `Abelian` from `groups` has too stringent a constraint. * `Additive` now lives in `Data.Semigroup.Additive`, but is still reexported From d8b04b40d31970b414524ea1d96e967baf390357 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 13 Oct 2021 20:43:05 -0400 Subject: [PATCH 6/8] Fix issue in change log --- ChangeLog.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index c82e8a4e..092b735c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -15,9 +15,6 @@ * `Additive` is still defined, because the `Abelian` from `groups` has too stringent a constraint. -* `Additive` now lives in `Data.Semigroup.Additive`, but is still reexported - from `Data.Patch` for compatability. - ## Unreleased * `Additive` now lives in `Data.Semigroup.Additive`, but is still reexported From 0f4d6341634cfe151c08b0c269024b17a9f0450c Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 1 Jan 2022 21:03:15 -0500 Subject: [PATCH 7/8] Actually do need `semialign` / split-these flag --- patch.cabal | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/patch.cabal b/patch.cabal index 40c0c7dd..0fb0249c 100644 --- a/patch.cabal +++ b/patch.cabal @@ -25,6 +25,11 @@ tested-with: GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.1 GHCJS ==8.4 +flag split-these + description: Use split these/semialign packages + manual: False + default: True + library hs-source-dirs: src default-language: Haskell2010 @@ -35,7 +40,6 @@ library , dependent-sum >= 0.6 && < 0.8 , lens >= 4.7 && < 5 , semigroupoids >= 4.0 && < 6 - , these >= 0.4 && < 1.2 , transformers >= 0.5.6.0 && < 0.6 , witherable >= 0.3 && < 0.5 @@ -57,6 +61,12 @@ library ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs default-extensions: PolyKinds + if flag(split-these) + build-depends: these >= 1 && <1.2 + , semialign >=1 && <1.2 + else + build-depends: these >= 0.4 && <0.9 + test-suite tests default-language: Haskell2010 type: exitcode-stdio-1.0 From d54a33464af5bd56de9c35f43411e452229983d3 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 6 Jan 2022 21:15:23 -0500 Subject: [PATCH 8/8] Mention the `split-these` flag is back --- ChangeLog.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 0305b95c..481ff371 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,9 +2,6 @@ ## Unreleased -* Remove the `split-these` flag. - We do not need it as we only use the `These` datatype which is provided in all versions. - * Stop defining `Group`; `Group` from the `groups` package can be used instead. Most of the instances are provided by `groups`, except the `Group