on develop help sign in
Merge remote-tracking branch 'origin/develop' into patch-map-inner-patch-desugar
09fe276John Ericson
CONTRIBUTING.md+1−1
@@ -16,7 +16,7 @@ Before opening an issue, please check whether your issue has already been report
16* Describe the issue you're encountering or the suggestion you're making
16* Describe the issue you're encountering or the suggestion you're making
17* 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.
17* 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.
18* Let us know what version of patch you were using. If you're using a github checkout, provide the git hash.
18* 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.
20
20
21## Submitting Changes
21## Submitting Changes
22
22
ChangeLog.md+4
@@ -6,6 +6,10 @@
6 Care is taken to make this as little of a breaking change as possible.
6 Care is taken to make this as little of a breaking change as possible.
7 In particular, `PatchMapWithMove` is a newtype of `PatchMapWithPatchingMove` as is the `NodeInfo` of `PatchMapWithPatchingMove`'s `NodeInfo`.
7 In particular, `PatchMapWithMove` is a newtype of `PatchMapWithPatchingMove` as is the `NodeInfo` of `PatchMapWithPatchingMove`'s `NodeInfo`.
8
8
9+## 0.0.3.2
10+
11+* Update version bounds
12+
9## 0.0.3.1
13## 0.0.3.1
10
14
11* Replace `fromJust` with something easier to debug.
15* Replace `fromJust` with something easier to debug.
README.md+6−4
@@ -1,8 +1,10 @@
1−## Patch
1+# patch
2
2
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)
4
4
5+Data structures for describing changes to other data structures.
6+
5−A `Patch` type represents a kind of change made to a datastructure.
7+A `Patch` type represents a kind of change made to a data structure.
6
8
7```haskell
9```haskell
8class Patch p where
10class Patch p where
@@ -12,7 +14,7 @@ class Patch p where
12 apply :: p -> PatchTarget p -> Maybe (PatchTarget p)
14 apply :: p -> PatchTarget p -> Maybe (PatchTarget p)
13```
15```
14
16
15−### Patching Maps
17+## Patching Maps
16For 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).
18For 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).
17
19
18`PatchMap` is defined as:
20`PatchMap` is defined as:
patch.cabal+13−9
@@ -1,7 +1,9 @@
1Name: patch
1Name: patch
2−Version: 0.0.3.1
2+Version: 0.0.3.2
3−Synopsis: Infrastructure for writing patches which act on other types.
3+Synopsis: Data structures for describing changes to other data structures.
4Description:
4Description:
5+ Data structures for describing changes to other data structures.
6+ .
5 In this library, a patch is something which can be applied, analogous to a
7 In this library, a patch is something which can be applied, analogous to a
6 function, and which distinguishes returning the argument it was provided from
8 function, and which distinguishes returning the argument it was provided from
7 returning something else.
9 returning something else.
@@ -12,7 +14,7 @@ Maintainer: maintainer@obsidian.systems
12Stability: Experimental
14Stability: Experimental
13Category: FRP
15Category: FRP
14Build-type: Simple
16Build-type: Simple
15−Cabal-version: >=1.9.2
17+Cabal-version: >=1.10
16homepage: https://obsidian.systems
18homepage: https://obsidian.systems
17bug-reports: https://github.com/reflex-frp/patch/issues
19bug-reports: https://github.com/reflex-frp/patch/issues
18extra-source-files:
20extra-source-files:
@@ -20,7 +22,7 @@ extra-source-files:
20 ChangeLog.md
22 ChangeLog.md
21
23
22tested-with:
24tested-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
24 GHCJS ==8.4
26 GHCJS ==8.4
25
27
26flag split-these
28flag split-these
@@ -30,15 +32,16 @@ flag split-these
30
32
31library
33library
32 hs-source-dirs: src
34 hs-source-dirs: src
35+ default-language: Haskell2010
33 build-depends: base >= 4.9 && < 4.14
36 build-depends: base >= 4.9 && < 4.14
34 , constraints-extras >= 0.3 && < 0.4
37 , constraints-extras >= 0.3 && < 0.4
35 , containers >= 0.6 && < 0.7
38 , containers >= 0.6 && < 0.7
36− , dependent-map >= 0.3 && < 0.4
39+ , dependent-map >= 0.3 && < 0.5
37− , dependent-sum >= 0.6 && < 0.7
40+ , dependent-sum >= 0.6 && < 0.8
38 , lens >= 4.7 && < 5
41 , lens >= 4.7 && < 5
39 , semigroupoids >= 4.0 && < 6
42 , semigroupoids >= 4.0 && < 6
40 , transformers >= 0.5.6.0 && < 0.6
43 , transformers >= 0.5.6.0 && < 0.6
41− , witherable >= 0.3 && < 0.3.2
44+ , witherable >= 0.3 && < 0.4
42
45
43 exposed-modules: Data.Functor.Misc
46 exposed-modules: Data.Functor.Misc
44 , Data.Monoid.DecidablyEmpty
47 , Data.Monoid.DecidablyEmpty
@@ -54,7 +57,7 @@ library
54 ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs
57 ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs
55
58
56 if flag(split-these)
59 if flag(split-these)
57− build-depends: these >= 1 && <1.1
60+ build-depends: these >= 1 && <1.2
58 , semialign >=1 && <1.2
61 , semialign >=1 && <1.2
59 , monoidal-containers >= 0.6 && < 0.7
62 , monoidal-containers >= 0.6 && < 0.7
60 else
63 else
@@ -62,6 +65,7 @@ library
62 , monoidal-containers == 0.4.0.0
65 , monoidal-containers == 0.4.0.0
63
66
64test-suite hlint
67test-suite hlint
68+ default-language: Haskell2010
65 type: exitcode-stdio-1.0
69 type: exitcode-stdio-1.0
66 main-is: hlint.hs
70 main-is: hlint.hs
67 hs-source-dirs: test
71 hs-source-dirs: test
@@ -69,7 +73,7 @@ test-suite hlint
69 , directory
73 , directory
70 , filepath
74 , filepath
71 , filemanip
75 , filemanip
72− , hlint < 2.1 || >= 2.2.2
76+ , hlint (< 2.1 || >= 2.2.2) && < 3
73 if impl(ghcjs)
77 if impl(ghcjs)
74 buildable: False
78 buildable: False
75
79
src/Data/Functor/Misc.hs+2−3
@@ -6,7 +6,6 @@
6{-# LANGUAGE GADTs #-}
6{-# LANGUAGE GADTs #-}
7{-# LANGUAGE LambdaCase #-}
7{-# LANGUAGE LambdaCase #-}
8{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE MultiParamTypeClasses #-}
9−{-# LANGUAGE PatternSynonyms #-}
10{-# LANGUAGE PolyKinds #-}
9{-# LANGUAGE PolyKinds #-}
11{-# LANGUAGE RankNTypes #-}
10{-# LANGUAGE RankNTypes #-}
12{-# LANGUAGE ScopedTypeVariables #-}
11{-# LANGUAGE ScopedTypeVariables #-}
@@ -48,7 +47,7 @@ import Data.IntMap (IntMap)
48import qualified Data.IntMap as IntMap
47import qualified Data.IntMap as IntMap
49import Data.Map (Map)
48import Data.Map (Map)
50import qualified Data.Map as Map
49import qualified Data.Map as Map
51−import Data.Some (Some(Some))
50+import Data.Some (Some, mkSome)
52import Data.These
51import Data.These
53import Data.Type.Equality ((:~:)(Refl))
52import Data.Type.Equality ((:~:)(Refl))
54import Data.Typeable hiding (Refl)
53import Data.Typeable hiding (Refl)
@@ -117,7 +116,7 @@ intMapWithFunctorToDMap = DMap.fromDistinctAscList . map (\(k, v) -> Const2 k :=
117-- | Convert a 'DMap' to a regular 'Map' by forgetting the types associated with
116-- | Convert a 'DMap' to a regular 'Map' by forgetting the types associated with
118-- the keys, using a function to remove the wrapping 'Functor'
117-- the keys, using a function to remove the wrapping 'Functor'
119weakenDMapWith :: (forall a. v a -> v') -> DMap k v -> Map (Some k) v'
118weakenDMapWith :: (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
121
120
122--------------------------------------------------------------------------------
121--------------------------------------------------------------------------------
123-- WrapArg
122-- WrapArg
src/Data/Patch/DMap.hs+3−1
@@ -14,7 +14,9 @@ import Data.Patch.Class
14import Data.Patch.IntMap
14import Data.Patch.IntMap
15import Data.Patch.Map
15import Data.Patch.Map
16
16
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 (..))
18import qualified Data.Dependent.Map as DMap
20import qualified Data.Dependent.Map as DMap
19import Data.Functor.Constant
21import Data.Functor.Constant
20import Data.Functor.Misc
22import Data.Functor.Misc
src/Data/Patch/DMapWithMove.hs+6−5
@@ -20,12 +20,13 @@ import Data.Patch.MapWithMove (PatchMapWithMove (..))
20import qualified Data.Patch.MapWithMove as MapWithMove
20import qualified Data.Patch.MapWithMove as MapWithMove
21
21
22import Data.Constraint.Extras
22import Data.Constraint.Extras
23−import Data.Dependent.Map (DMap, DSum (..), GCompare (..))
23+import Data.Dependent.Map (DMap)
24+import Data.Dependent.Sum (DSum (..))
24import qualified Data.Dependent.Map as DMap
25import qualified Data.Dependent.Map as DMap
25import Data.Functor.Constant
26import Data.Functor.Constant
26import Data.Functor.Misc
27import Data.Functor.Misc
27import Data.Functor.Product
28import Data.Functor.Product
28−import Data.GADT.Compare (GEq (..))
29+import Data.GADT.Compare (GEq (..), GCompare (..))
29import Data.GADT.Show (GShow, gshow)
30import Data.GADT.Show (GShow, gshow)
30import qualified Data.Map as Map
31import qualified Data.Map as Map
31import Data.Maybe
32import Data.Maybe
@@ -33,7 +34,7 @@ import Data.Monoid.DecidablyEmpty
33#if !MIN_VERSION_base(4,11,0)
34#if !MIN_VERSION_base(4,11,0)
34import Data.Semigroup (Semigroup (..))
35import Data.Semigroup (Semigroup (..))
35#endif
36#endif
36−import Data.Some (Some(Some))
37+import Data.Some (Some, mkSome)
37import Data.These
38import Data.These
38
39
39-- | 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
40-- | 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
317 { MapWithMove._nodeInfo_from = case _nodeInfo_from ni of
318 { MapWithMove._nodeInfo_from = case _nodeInfo_from ni of
318 From_Insert v -> MapWithMove.From_Insert $ f v
319 From_Insert v -> MapWithMove.From_Insert $ f v
319 From_Delete -> MapWithMove.From_Delete
320 From_Delete -> MapWithMove.From_Delete
320− From_Move k -> MapWithMove.From_Move $ Some k
321+ From_Move k -> MapWithMove.From_Move $ mkSome k
321− , MapWithMove._nodeInfo_to = Some <$> getComposeMaybe (_nodeInfo_to ni)
322+ , MapWithMove._nodeInfo_to = mkSome <$> getComposeMaybe (_nodeInfo_to ni)
322 }
323 }
323
324
324-- |"Weaken" a @'PatchDMapWithMove' (Const2 k a) v@ to a @'PatchMapWithMove' k v'@. Weaken is in scare quotes because the 'Const2' has already disabled any
325-- |"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
59-- | Map an effectful function @Int -> a -> f b@ over all @a@s in the given @'PatchIntMap' a@
59-- | Map an effectful function @Int -> a -> f b@ over all @a@s in the given @'PatchIntMap' a@
60-- (that is, all inserts/updates), producing a @f (PatchIntMap b)@.
60-- (that is, all inserts/updates), producing a @f (PatchIntMap b)@.
61traverseIntMapPatchWithKey :: Applicative f => (Int -> a -> f b) -> PatchIntMap a -> f (PatchIntMap b)
61traverseIntMapPatchWithKey :: 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
63
63
64-- | Extract all @a@s inserted/updated by the given @'PatchIntMap' a@.
64-- | Extract all @a@s inserted/updated by the given @'PatchIntMap' a@.
65patchIntMapNewElements :: PatchIntMap a -> [a]
65patchIntMapNewElements :: PatchIntMap a -> [a]
test/hlint.hs+2−1
@@ -1,7 +1,7 @@
1module Main where
1module Main where
2
2
3import Control.Monad
3import Control.Monad
4−import Language.Haskell.HLint3 (hlint)
4+import Language.Haskell.HLint (hlint)
5import System.Directory
5import System.Directory
6import System.Exit (exitFailure, exitSuccess)
6import System.Exit (exitFailure, exitSuccess)
7import System.FilePath
7import System.FilePath
@@ -23,6 +23,7 @@ main = do
23 , "--ignore=Reduce duplication"
23 , "--ignore=Reduce duplication"
24 , "--cpp-define=USE_TEMPLATE_HASKELL"
24 , "--cpp-define=USE_TEMPLATE_HASKELL"
25 , "--ignore=Use tuple-section"
25 , "--ignore=Use tuple-section"
26+ , "--ignore=Unused LANGUAGE pragma" -- hlint3 falsely believes that TypeOperators is not needed
26 ]
27 ]
27 recurseInto = and <$> sequence
28 recurseInto = and <$> sequence
28 [ fileType ==? Directory
29 [ fileType ==? Directory