Skip to content

Commit aacb8a6

Browse files
committed
Merge branch 'develop' into no-group
2 parents a9a9af4 + 0019cce commit aacb8a6

File tree

8 files changed

+417
-274
lines changed

8 files changed

+417
-274
lines changed

.github/workflows/haskell.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ jobs:
4343
run: cabal build --enable-tests --enable-benchmarks all
4444
- name: Run tests
4545
run: cabal test all
46+
- name: Build Docs
47+
run: cabal haddock

ChangeLog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
* `Additive` now lives in `Data.Semigroup.Additive`, but is still reexported
1919
from `Data.Patch` for compatability.
2020

21+
## Unreleased
22+
23+
* Rewrite `PatchMapWithMove` in terms of `PatchMapWithPatchingMove`.
24+
Care is taken to make this not a breaking change.
25+
In particular, `PatchMapWithMove` is a newtype of `PatchMapWithPatchingMove`, as is the `NodeInfo` and `From` of `PatchMapWithPatchingMove`'s versions of those.
26+
There are complete constructor and field patterns too, and everything is
27+
exported under the newtype as real constructors and fields would be.
28+
2129
## 0.0.4.0
2230

2331
* Enable PolyKinds

patch.cabal

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ library
5757
ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs
5858
default-extensions: PolyKinds
5959

60+
test-suite tests
61+
default-language: Haskell2010
62+
type: exitcode-stdio-1.0
63+
main-is: tests.hs
64+
hs-source-dirs: test
65+
build-depends: base
66+
, patch
67+
, containers
68+
, hedgehog
69+
, HUnit
70+
if impl(ghcjs)
71+
buildable: False
72+
6073
test-suite hlint
6174
default-language: Haskell2010
6275
type: exitcode-stdio-1.0

src/Data/Patch/Class.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE ScopedTypeVariables #-}
23
{-# LANGUAGE TypeFamilies #-}
34
-- | The interface for types which represent changes made to other types
45
module Data.Patch.Class where
56

67
import Data.Functor.Identity
8+
import Data.Kind (Type)
79
import Data.Maybe
810
#if !MIN_VERSION_base(4,11,0)
911
import Data.Semigroup (Semigroup(..))
@@ -15,7 +17,7 @@ import Data.Proxy
1517
-- If an instance of 'Patch' is also an instance of 'Semigroup', it should obey
1618
-- the law that @applyAlways (f <> g) == applyAlways f . applyAlways g@.
1719
class Patch p where
18-
type PatchTarget p :: *
20+
type PatchTarget p :: Type
1921
-- | Apply the patch @p a@ to the value @a@. If no change is needed, return
2022
-- 'Nothing'.
2123
apply :: p -> PatchTarget p -> Maybe (PatchTarget p)
@@ -30,7 +32,7 @@ instance Patch (Identity a) where
3032
apply (Identity a) _ = Just a
3133

3234
-- | 'Proxy' can be used as a 'Patch' that does nothing.
33-
instance Patch (Proxy (a :: *)) where
35+
instance forall (a :: Type). Patch (Proxy a) where
3436
type PatchTarget (Proxy a) = a
3537
apply ~Proxy _ = Nothing
3638

src/Data/Patch/DMapWithMove.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ moveDMapKey src dst = case src `geq` dst of
220220
-- @
221221
-- let aMay = DMap.lookup a dmap
222222
-- bMay = DMap.lookup b dmap
223-
-- in maybe id (DMap.insert a) (bMay `mplus` aMay)
224-
-- . maybe id (DMap.insert b) (aMay `mplus` bMay)
223+
-- in maybe id (DMap.insert a) (bMay <> aMay)
224+
-- . maybe id (DMap.insert b) (aMay <> bMay)
225225
-- . DMap.delete a . DMap.delete b $ dmap
226226
-- @
227227
swapDMapKey :: GCompare k => k a -> k a -> PatchDMapWithMove k v

0 commit comments

Comments
 (0)