patch 0.0.3.1 → 0.0.3.2
raw patch · 8 files changed
+37/−24 lines, 8 filesdep ~basedep ~dependent-mapdep ~dependent-sumnew-uploader
Dependency ranges changed: base, dependent-map, dependent-sum, hlint, these, witherable
Files
- ChangeLog.md +4/−0
- 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
ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for patch +## 0.0.3.2++* Update version bounds+ ## 0.0.3.1 * Replace `fromJust` with something easier to debug.
README.md view
@@ -1,9 +1,11 @@-## Patch+# patch -Infrastructure for writing patches which act on other types.+[](https://haskell.org) [](https://hackage.haskell.org/package/patch) [](https://matrix.hackage.haskell.org/#/package/patch) [](https://travis-ci.org/reflex-frp/patch) [](https://github.com/reflex-frp/patch/LICENSE) -A `Patch` type represents a kind of change made to a datastructure.+Data structures for describing changes to other data structures. +A `Patch` type represents a kind of change made to a data structure.+ ```haskell class Patch p where type PatchTarget p :: *@@ -12,7 +14,7 @@ apply :: p -> PatchTarget p -> Maybe (PatchTarget p) ``` -### Patching Maps+## Patching Maps For 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). `PatchMap` is defined as:
patch.cabal view
@@ -1,7 +1,9 @@ Name: patch-Version: 0.0.3.1-Synopsis: Infrastructure for writing patches which act on other types.+Version: 0.0.3.2+Synopsis: Data structures for describing changes to other data structures. Description:+ Data structures for describing changes to other data structures.+ . In this library, a patch is something which can be applied, analogous to a function, and which distinguishes returning the argument it was provided from returning something else.@@ -12,7 +14,7 @@ Stability: Experimental Category: FRP Build-type: Simple-Cabal-version: >=1.9.2+Cabal-version: >=1.10 homepage: https://obsidian.systems bug-reports: https://github.com/reflex-frp/patch/issues extra-source-files:@@ -20,7 +22,7 @@ ChangeLog.md tested-with:- GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.1+ GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.1 GHCJS ==8.4 flag split-these@@ -30,15 +32,16 @@ library hs-source-dirs: src+ default-language: Haskell2010 build-depends: base >= 4.9 && < 4.14 , constraints-extras >= 0.3 && < 0.4 , containers >= 0.6 && < 0.7- , dependent-map >= 0.3 && < 0.4- , dependent-sum >= 0.6 && < 0.7+ , dependent-map >= 0.3 && < 0.5+ , dependent-sum >= 0.6 && < 0.8 , lens >= 4.7 && < 5 , semigroupoids >= 4.0 && < 6 , transformers >= 0.5.6.0 && < 0.6- , witherable >= 0.3 && < 0.3.2+ , witherable >= 0.3 && < 0.4 exposed-modules: Data.Functor.Misc , Data.Monoid.DecidablyEmpty@@ -54,7 +57,7 @@ ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs if flag(split-these)- build-depends: these >= 1 && <1.1+ build-depends: these >= 1 && <1.2 , semialign >=1 && <1.2 , monoidal-containers >= 0.6 && < 0.7 else@@ -62,6 +65,7 @@ , monoidal-containers == 0.4.0.0 test-suite hlint+ default-language: Haskell2010 type: exitcode-stdio-1.0 main-is: hlint.hs hs-source-dirs: test@@ -69,7 +73,7 @@ , directory , filepath , filemanip- , hlint < 2.1 || >= 2.2.2+ , hlint (< 2.1 || >= 2.2.2) && < 3 if impl(ghcjs) buildable: False
src/Data/Functor/Misc.hs view
@@ -6,7 +6,6 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -48,7 +47,7 @@ import qualified Data.IntMap as IntMap import Data.Map (Map) import qualified Data.Map as Map-import Data.Some (Some(Some))+import Data.Some (Some, mkSome) import Data.These import Data.Type.Equality ((:~:)(Refl)) import Data.Typeable hiding (Refl)@@ -117,7 +116,7 @@ -- | Convert a 'DMap' to a regular 'Map' by forgetting the types associated with -- the keys, using a function to remove the wrapping 'Functor' weakenDMapWith :: (forall a. v a -> v') -> DMap k v -> Map (Some k) v'-weakenDMapWith f = Map.fromDistinctAscList . map (\(k :=> v) -> (Some k, f v)) . DMap.toAscList+weakenDMapWith f = Map.fromDistinctAscList . map (\(k :=> v) -> (mkSome k, f v)) . DMap.toAscList -------------------------------------------------------------------------------- -- WrapArg
src/Data/Patch/DMap.hs view
@@ -14,7 +14,9 @@ import Data.Patch.IntMap import Data.Patch.Map -import Data.Dependent.Map (DMap, DSum (..), GCompare (..))+import Data.Dependent.Map (DMap)+import Data.Dependent.Sum (DSum (..))+import Data.GADT.Compare (GCompare (..)) import qualified Data.Dependent.Map as DMap import Data.Functor.Constant import Data.Functor.Misc
src/Data/Patch/DMapWithMove.hs view
@@ -20,12 +20,13 @@ import qualified Data.Patch.MapWithMove as MapWithMove import Data.Constraint.Extras-import Data.Dependent.Map (DMap, DSum (..), GCompare (..))+import Data.Dependent.Map (DMap)+import Data.Dependent.Sum (DSum (..)) import qualified Data.Dependent.Map as DMap import Data.Functor.Constant import Data.Functor.Misc import Data.Functor.Product-import Data.GADT.Compare (GEq (..))+import Data.GADT.Compare (GEq (..), GCompare (..)) import Data.GADT.Show (GShow, gshow) import qualified Data.Map as Map import Data.Maybe@@ -33,7 +34,7 @@ #if !MIN_VERSION_base(4,11,0) import Data.Semigroup (Semigroup (..)) #endif-import Data.Some (Some(Some))+import Data.Some (Some, mkSome) import Data.These -- | 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 @@ { MapWithMove._nodeInfo_from = case _nodeInfo_from ni of From_Insert v -> MapWithMove.From_Insert $ f v From_Delete -> MapWithMove.From_Delete- From_Move k -> MapWithMove.From_Move $ Some k- , MapWithMove._nodeInfo_to = Some <$> getComposeMaybe (_nodeInfo_to ni)+ From_Move k -> MapWithMove.From_Move $ mkSome k+ , MapWithMove._nodeInfo_to = mkSome <$> getComposeMaybe (_nodeInfo_to ni) } -- |"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 view
@@ -59,7 +59,7 @@ -- | Map an effectful function @Int -> a -> f b@ over all @a@s in the given @'PatchIntMap' a@ -- (that is, all inserts/updates), producing a @f (PatchIntMap b)@. traverseIntMapPatchWithKey :: Applicative f => (Int -> a -> f b) -> PatchIntMap a -> f (PatchIntMap b)-traverseIntMapPatchWithKey f (PatchIntMap m) = PatchIntMap <$> IntMap.traverseWithKey (\k mv -> traverse (f k) mv) m+traverseIntMapPatchWithKey f (PatchIntMap m) = PatchIntMap <$> IntMap.traverseWithKey (traverse . f) m -- | Extract all @a@s inserted/updated by the given @'PatchIntMap' a@. patchIntMapNewElements :: PatchIntMap a -> [a]
test/hlint.hs view
@@ -1,7 +1,7 @@ module Main where import Control.Monad-import Language.Haskell.HLint3 (hlint)+import Language.Haskell.HLint (hlint) import System.Directory import System.Exit (exitFailure, exitSuccess) import System.FilePath@@ -23,6 +23,7 @@ , "--ignore=Reduce duplication" , "--cpp-define=USE_TEMPLATE_HASKELL" , "--ignore=Use tuple-section"+ , "--ignore=Unused LANGUAGE pragma" -- hlint3 falsely believes that TypeOperators is not needed ] recurseInto = and <$> sequence [ fileType ==? Directory