Skip to content

Compatibility with LTS-12.4 #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Data/Patch/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{-# LANGUAGE BangPatterns, Trustworthy #-}
-- | For day-to-day use, please see "Data.Patch"
module Data.Patch.Internal where
import Data.Monoid
import Data.Monoid hiding ((<>))
import Data.Semigroup (Semigroup (..))
import Data.Ord
import qualified Data.List as List
import qualified Data.Vector as Vector
Expand Down Expand Up @@ -145,9 +146,8 @@ normalise grp = let (inserts, deletes, replaces) = partition3 grp
normalise' [] (d:_) _ = [d]
normalise' _ _ _ = error "Impossible!"

instance Eq a => Monoid (Patch a) where
mempty = Patch []
mappend (Patch a) (Patch b) = Patch $ merge a b (0 :: Int)
instance Eq a => Semigroup (Patch a) where
(<>) (Patch a) (Patch b) = Patch $ merge a b (0 :: Int)
where
merge [] ys off = map (over index (+ off)) ys
merge xs [] _ = xs
Expand All @@ -171,6 +171,10 @@ instance Eq a => Monoid (Patch a) where
replace _ o n | o == n = id
replace i o n | otherwise = (Replace i o n :)

instance Eq a => Monoid (Patch a) where
mempty = Patch []
mappend = (<>)

-- | Returns true if a patch can be safely applied to a document, that is,
-- @applicable p d@ holds when @d@ is a valid source document for the patch @p@.
applicable :: (Eq a) => Patch a -> Vector a -> Bool
Expand Down Expand Up @@ -317,7 +321,7 @@ theirs :: a -> a -> a
theirs = flip const

-- | A convenience version of 'transformWith' which resolves conflicts using 'mappend'.
transform :: (Eq a, Monoid a) => Patch a -> Patch a -> (Patch a, Patch a)
transform :: (Eq a, Semigroup a) => Patch a -> Patch a -> (Patch a, Patch a)
transform = transformWith (<>)

-- | Compute the difference between two documents, using the Wagner-Fischer algorithm. O(mn) time and space.
Expand Down
22 changes: 11 additions & 11 deletions patches-vector.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- documentation, see http://haskell.org/cabal/users-guide/

name: patches-vector
version: 0.1.5.4
version: 0.1.6
synopsis: Patches (diffs) on vectors: composable, mergeable, and invertible.
description: A patch is a collection of modifications (edits) to be made to a sequence of elements. Commonly
found in version control systems, patches are also a simple example of a groupoid, supporting (partial) composition
Expand Down Expand Up @@ -33,28 +33,28 @@ library
, Data.Patch.Internal
build-depends: base >=4.7 && <5
, edit-distance-vector >=1.0 && <1.1
, vector >= 0.10 && < 0.12
, vector >= 0.10 && < 0.13
, microlens >= 0.2 && < 0.5
default-language: Haskell2010

test-suite doctest-patches-vector
type: exitcode-stdio-1.0
main-is: doctest.hs
build-depends: base >= 4.7 && < 5
, QuickCheck >= 2.7 && < 2.9
, QuickCheck >= 2.7 && < 2.12
, patches-vector
, doctest >= 0.9 && < 0.12
, doctest >= 0.9 && < 0.17
default-language: Haskell2010

test-suite benchmarks-patches-vector
type: exitcode-stdio-1.0
main-is: benchmarks.hs
hs-source-dirs: bm
build-depends: base >= 4.7 && < 5
, QuickCheck >= 2.7 && < 2.9
, QuickCheck >= 2.7 && < 2.12
, patches-vector
, criterion >= 1.1 && < 1.2
, vector >= 0.10 && <0.12
, criterion >= 1.1 && < 1.45
, vector >= 0.10 && <0.13
default-language: Haskell2010

test-suite spec-patches-vector
Expand All @@ -65,9 +65,9 @@ test-suite spec-patches-vector
, Test.Util
, Test.UtilSpec
build-depends: base >= 4.7 && < 5
, QuickCheck >= 2.7 && < 2.9
, QuickCheck >= 2.7 && < 2.12
, patches-vector
, criterion >= 1.1 && < 1.2
, vector >= 0.10 && <0.12
, hspec >= 2.1 && < 2.3
, criterion >= 1.1 && < 1.5
, vector >= 0.10 && <0.13
, hspec >= 2.1 && < 2.6
default-language: Haskell2010
27 changes: 1 addition & 26 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,7 @@
# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md
resolver: lts-12.4

# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-7.10

# Local packages, usually specified by relative directory name
packages:
- '.'

# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps:
- edit-distance-vector-1.0.0.4
# Override default flag values for local packages and extra-deps
flags: {}

# Extra package databases containing global packages
extra-package-dbs: []

# Control whether we use the GHC we find on the path
# system-ghc: true

# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: >= 0.1.4.0

# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64

# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]