on develop help sign in
Merge remote-tracking branch 'origin/develop' into patch-map-inner-patch-desugar
commit09fe276e29aad4033dd91df037306c50f8a0c83a authorJohn Ericson <John.Ericson@Obsidian.Systems> dateMon 7 Dec 2020, 12:01 (6 years ago) parent9705224064a0e8
9 files changed+38−25
CONTRIBUTING.md+1−1 ChangeLog.md+4 README.md+6−4 patch.cabal+13−9 src/Data/Functor/Misc.hs+2−3 src/Data/Patch/DMap.hs+3−1 src/Data/Patch/DMapWithMove.hs+6−5 src/Data/Patch/IntMap.hs+1−1 test/hlint.hs+2−1
CONTRIBUTING.md+1−1
@@ -16,7 +16,7 @@ Before opening an issue, please check whether your issue has already been report
1616* Describe the issue you're encountering or the suggestion you're making
1717* Include any relevant steps to reproduce or code samples you can. It's always easier for us to debug if we have something that demonstrates the error.
1818* Let us know what version of patch you were using. If you're using a github checkout, provide the git hash.
19−* Describe how you're building patch (i.e., via patch-platform, cabal install, stack, obelisk, etc.). If you're using patch-platform or obelisk, provide the git hash of your checkout.
19+* Describe how you're building patch (i.e., via reflex-platform, cabal install, stack, obelisk, etc.). If you're using reflex-platform or obelisk, provide the git hash of your checkout.
2020
2121## Submitting Changes
2222
ChangeLog.md+4
@@ -6,6 +6,10 @@
66 Care is taken to make this as little of a breaking change as possible.
77 In particular, `PatchMapWithMove` is a newtype of `PatchMapWithPatchingMove` as is the `NodeInfo` of `PatchMapWithPatchingMove`'s `NodeInfo`.
88
9+## 0.0.3.2
10+
11+* Update version bounds
12+
913## 0.0.3.1
1014
1115* Replace `fromJust` with something easier to debug.
README.md+6−4
@@ -1,8 +1,10 @@
1−## Patch
1+# patch
22
3−Infrastructure for writing patches which act on other types.
3+[![Haskell](https://img.shields.io/badge/language-Haskell-orange.svg)](https://haskell.org) [![Hackage](https://img.shields.io/hackage/v/patch.svg)](https://hackage.haskell.org/package/patch) [![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/patch/badge)](https://matrix.hackage.haskell.org/#/package/patch) [![Travis CI](https://api.travis-ci.org/reflex-frp/patch.svg?branch=develop)](https://travis-ci.org/reflex-frp/patch) [![BSD3 License](https://img.shields.io/badge/license-BSD3-blue.svg)](https://github.com/reflex-frp/patch/LICENSE)
44
5−A `Patch` type represents a kind of change made to a datastructure.
5+Data structures for describing changes to other data structures.
6+
7+A `Patch` type represents a kind of change made to a data structure.
68
79```haskell
810class Patch p where
@@ -12,7 +14,7 @@ class Patch p where
1214 apply :: p -> PatchTarget p -> Maybe (PatchTarget p)
1315```
1416
15−### Patching Maps
17+## Patching Maps
1618For example, `Data.Patch.Map` defines the `PatchMap` type which can be used to patch `Map`s. A `PatchMap` represents updates to a `Map` that can insert, remove, or replace items in the `Map`. In this example, the `Map` is the `PatchTarget` and the `PatchMap` is the `Patch`. Keep in mind that there are many other possible `Patch`es that can be applied to a `Map` (i.e., `Map` can be the `PatchTarget` for many different `Patch` instances).
1719
1820`PatchMap` is defined as:
patch.cabal+13−9
@@ -1,7 +1,9 @@
11Name: patch
2−Version: 0.0.3.1
3−Synopsis: Infrastructure for writing patches which act on other types.
2+Version: 0.0.3.2
3+Synopsis: Data structures for describing changes to other data structures.
44Description:
5+ Data structures for describing changes to other data structures.
6+ .
57 In this library, a patch is something which can be applied, analogous to a
68 function, and which distinguishes returning the argument it was provided from
79 returning something else.
@@ -12,7 +14,7 @@ Maintainer: maintainer@obsidian.systems
1214Stability: Experimental
1315Category: FRP
1416Build-type: Simple
15−Cabal-version: >=1.9.2
17+Cabal-version: >=1.10
1618homepage: https://obsidian.systems
1719bug-reports: https://github.com/reflex-frp/patch/issues
1820extra-source-files:
@@ -20,7 +22,7 @@ extra-source-files:
2022 ChangeLog.md
2123
2224tested-with:
23− 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
2426 GHCJS ==8.4
2527
2628flag split-these
@@ -30,15 +32,16 @@ flag split-these
3032
3133library
3234 hs-source-dirs: src
35+ default-language: Haskell2010
3336 build-depends: base >= 4.9 && < 4.14
3437 , constraints-extras >= 0.3 && < 0.4
3538 , containers >= 0.6 && < 0.7
36− , dependent-map >= 0.3 && < 0.4
37− , dependent-sum >= 0.6 && < 0.7
39+ , dependent-map >= 0.3 && < 0.5
40+ , dependent-sum >= 0.6 && < 0.8
3841 , lens >= 4.7 && < 5
3942 , semigroupoids >= 4.0 && < 6
4043 , transformers >= 0.5.6.0 && < 0.6
41− , witherable >= 0.3 && < 0.3.2
44+ , witherable >= 0.3 && < 0.4
4245
4346 exposed-modules: Data.Functor.Misc
4447 , Data.Monoid.DecidablyEmpty
@@ -54,7 +57,7 @@ library
5457 ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs
5558
5659 if flag(split-these)
57− build-depends: these >= 1 && <1.1
60+ build-depends: these >= 1 && <1.2
5861 , semialign >=1 && <1.2
5962 , monoidal-containers >= 0.6 && < 0.7
6063 else
@@ -62,6 +65,7 @@ library
6265 , monoidal-containers == 0.4.0.0
6366
6467test-suite hlint
68+ default-language: Haskell2010
6569 type: exitcode-stdio-1.0
6670 main-is: hlint.hs
6771 hs-source-dirs: test
@@ -69,7 +73,7 @@ test-suite hlint
6973 , directory
7074 , filepath
7175 , filemanip
72− , hlint < 2.1 || >= 2.2.2
76+ , hlint (< 2.1 || >= 2.2.2) && < 3
7377 if impl(ghcjs)
7478 buildable: False
7579
src/Data/Functor/Misc.hs+2−3
@@ -6,7 +6,6 @@
66{-# LANGUAGE GADTs #-}
77{-# LANGUAGE LambdaCase #-}
88{-# LANGUAGE MultiParamTypeClasses #-}
9−{-# LANGUAGE PatternSynonyms #-}
109{-# LANGUAGE PolyKinds #-}
1110{-# LANGUAGE RankNTypes #-}
1211{-# LANGUAGE ScopedTypeVariables #-}
@@ -48,7 +47,7 @@ import Data.IntMap (IntMap)
4847import qualified Data.IntMap as IntMap
4948import Data.Map (Map)
5049import qualified Data.Map as Map
51−import Data.Some (Some(Some))
50+import Data.Some (Some, mkSome)
5251import Data.These
5352import Data.Type.Equality ((:~:)(Refl))
5453import Data.Typeable hiding (Refl)
@@ -117,7 +116,7 @@ intMapWithFunctorToDMap = DMap.fromDistinctAscList . map (\(k, v) -> Const2 k :=
117116-- | Convert a 'DMap' to a regular 'Map' by forgetting the types associated with
118117-- the keys, using a function to remove the wrapping 'Functor'
119118weakenDMapWith :: (forall a. v a -> v') -> DMap k v -> Map (Some k) v'
120−weakenDMapWith f = Map.fromDistinctAscList . map (\(k :=> v) -> (Some k, f v)) . DMap.toAscList
119+weakenDMapWith f = Map.fromDistinctAscList . map (\(k :=> v) -> (mkSome k, f v)) . DMap.toAscList
121120
122121--------------------------------------------------------------------------------
123122-- WrapArg
src/Data/Patch/DMap.hs+3−1
@@ -14,7 +14,9 @@ import Data.Patch.Class
1414import Data.Patch.IntMap
1515import Data.Patch.Map
1616
17−import Data.Dependent.Map (DMap, DSum (..), GCompare (..))
17+import Data.Dependent.Map (DMap)
18+import Data.Dependent.Sum (DSum (..))
19+import Data.GADT.Compare (GCompare (..))
1820import qualified Data.Dependent.Map as DMap
1921import Data.Functor.Constant
2022import Data.Functor.Misc
src/Data/Patch/DMapWithMove.hs+6−5
@@ -20,12 +20,13 @@ import Data.Patch.MapWithMove (PatchMapWithMove (..))
2020import qualified Data.Patch.MapWithMove as MapWithMove
2121
2222import Data.Constraint.Extras
23−import Data.Dependent.Map (DMap, DSum (..), GCompare (..))
23+import Data.Dependent.Map (DMap)
24+import Data.Dependent.Sum (DSum (..))
2425import qualified Data.Dependent.Map as DMap
2526import Data.Functor.Constant
2627import Data.Functor.Misc
2728import Data.Functor.Product
28−import Data.GADT.Compare (GEq (..))
29+import Data.GADT.Compare (GEq (..), GCompare (..))
2930import Data.GADT.Show (GShow, gshow)
3031import qualified Data.Map as Map
3132import Data.Maybe
@@ -33,7 +34,7 @@ import Data.Monoid.DecidablyEmpty
3334#if !MIN_VERSION_base(4,11,0)
3435import Data.Semigroup (Semigroup (..))
3536#endif
36−import Data.Some (Some(Some))
37+import Data.Some (Some, mkSome)
3738import Data.These
3839
3940-- | Like 'PatchMapWithMove', but for 'DMap'. Each key carries a 'NodeInfo' which describes how it will be changed by the patch and connects move sources and
@@ -317,8 +318,8 @@ weakenPatchDMapWithMoveWith f (PatchDMapWithMove p) = PatchMapWithMove $ weakenD
317318 { MapWithMove._nodeInfo_from = case _nodeInfo_from ni of
318319 From_Insert v -> MapWithMove.From_Insert $ f v
319320 From_Delete -> MapWithMove.From_Delete
320− From_Move k -> MapWithMove.From_Move $ Some k
321− , MapWithMove._nodeInfo_to = Some <$> getComposeMaybe (_nodeInfo_to ni)
321+ From_Move k -> MapWithMove.From_Move $ mkSome k
322+ , MapWithMove._nodeInfo_to = mkSome <$> getComposeMaybe (_nodeInfo_to ni)
322323 }
323324
324325-- |"Weaken" a @'PatchDMapWithMove' (Const2 k a) v@ to a @'PatchMapWithMove' k v'@. Weaken is in scare quotes because the 'Const2' has already disabled any
src/Data/Patch/IntMap.hs+1−1
@@ -59,7 +59,7 @@ mapIntMapPatchWithKey f (PatchIntMap m) = PatchIntMap $ IntMap.mapWithKey (\ k m
5959-- | Map an effectful function @Int -> a -> f b@ over all @a@s in the given @'PatchIntMap' a@
6060-- (that is, all inserts/updates), producing a @f (PatchIntMap b)@.
6161traverseIntMapPatchWithKey :: Applicative f => (Int -> a -> f b) -> PatchIntMap a -> f (PatchIntMap b)
62−traverseIntMapPatchWithKey f (PatchIntMap m) = PatchIntMap <$> IntMap.traverseWithKey (\k mv -> traverse (f k) mv) m
62+traverseIntMapPatchWithKey f (PatchIntMap m) = PatchIntMap <$> IntMap.traverseWithKey (traverse . f) m
6363
6464-- | Extract all @a@s inserted/updated by the given @'PatchIntMap' a@.
6565patchIntMapNewElements :: PatchIntMap a -> [a]
test/hlint.hs+2−1
@@ -1,7 +1,7 @@
11module Main where
22
33import Control.Monad
4−import Language.Haskell.HLint3 (hlint)
4+import Language.Haskell.HLint (hlint)
55import System.Directory
66import System.Exit (exitFailure, exitSuccess)
77import System.FilePath
@@ -23,6 +23,7 @@ main = do
2323 , "--ignore=Reduce duplication"
2424 , "--cpp-define=USE_TEMPLATE_HASKELL"
2525 , "--ignore=Use tuple-section"
26+ , "--ignore=Unused LANGUAGE pragma" -- hlint3 falsely believes that TypeOperators is not needed
2627 ]
2728 recurseInto = and <$> sequence
2829 [ fileType ==? Directory