packages feed

fast-myers-diff 0.0.0 → 0.0.1

raw patch · 3 files changed

+29/−18 lines, 3 filesdep +deepseqPVP ok

version bump matches the API change (PVP)

Dependencies added: deepseq

API changes (from Hackage documentation)

+ Myers.Diff: instance (Control.DeepSeq.NFData a, Control.DeepSeq.NFData b) => Control.DeepSeq.NFData (Myers.Diff.PolyDiff a b)
+ Myers.Diff: instance GHC.Generics.Generic (Myers.Diff.PolyDiff a b)

Files

+ Changelog.md view
@@ -0,0 +1,5 @@+# Revision history for fast-myers-diff++## 0.0.1 -- 2024-09-08++- Added `NFData` instance for `PolyDiff`
fast-myers-diff.cabal view
@@ -1,16 +1,16 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.2.+-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack  name:           fast-myers-diff-version:        0.0.0+version:        0.0.1 synopsis:       A fast implementation of the Myers diff algorithm. description:    A fast implementation of the diffing algorithm described in 'An O(ND) Difference Algorithm and Its Variations' by Eugene W. Myers. category:       Testing-homepage:       https://github.com/NorfairKing/sydtest#readme-bug-reports:    https://github.com/NorfairKing/sydtest/issues+homepage:       https://github.com/NorfairKing/fast-myers-diff#readme+bug-reports:    https://github.com/NorfairKing/fast-myers-diff/issues author:         Tom Sydney Kerckhove maintainer:     syd@cs-syd.eu copyright:      Copyright (c) 2023 Tom Sydney Kerckhove@@ -19,10 +19,11 @@ build-type:     Simple extra-source-files:     LICENSE+    Changelog.md  source-repository head   type: git-  location: https://github.com/NorfairKing/sydtest+  location: https://github.com/NorfairKing/fast-myers-diff  library   exposed-modules:@@ -33,6 +34,7 @@       src   build-depends:       base >=4.7 && <5+    , deepseq     , dlist     , text     , vector
src/Myers/Diff.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE DeriveAnyClass #-}+{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -35,6 +37,7 @@   ) where +import Control.DeepSeq (NFData) import Control.Monad import Control.Monad.ST import Data.DList (DList)@@ -48,6 +51,7 @@ import qualified Data.Vector as V import Data.Vector.Mutable (MVector) import qualified Data.Vector.Mutable as MV+import GHC.Generics  type Diff a = PolyDiff a a @@ -59,7 +63,7 @@ -- of equality that doesn't check all data (for example, if you are using a -- custom equality relation to only perform equality on side of a tuple). data PolyDiff a b = First a | Second b | Both a b-  deriving (Show, Eq)+  deriving (Show, Eq, Generic, NFData)  bimapPolyDiff :: (a -> c) -> (b -> d) -> PolyDiff a b -> PolyDiff c d bimapPolyDiff f g = \case@@ -70,7 +74,7 @@ -- | -- -- For backward compatibility with 'Diff', use more specific functions if you can.-getDiff :: Eq a => [a] -> [a] -> [Diff a]+getDiff :: (Eq a) => [a] -> [a] -> [Diff a] getDiff = getDiffBy (==)  -- |@@ -82,7 +86,7 @@ -- | -- -- For backward compatibility with 'Diff', use more specific functions if you can.-getGroupedDiff :: Eq a => [a] -> [a] -> [Diff [a]]+getGroupedDiff :: (Eq a) => [a] -> [a] -> [Diff [a]] getGroupedDiff = getGroupedDiffBy (==)  -- |@@ -120,7 +124,7 @@ -- | Diff two 'Vector's -- -- Prefer 'getGroupedVectorDiff' for performance reasons.-getVectorDiff :: Eq a => Vector a -> Vector a -> Vector (Diff a)+getVectorDiff :: (Eq a) => Vector a -> Vector a -> Vector (Diff a) getVectorDiff = getVectorDiffBy (==)  -- | Diff two 'Vector's with different types using a custom equality operator@@ -130,7 +134,7 @@ getVectorDiffBy eq old new = computeDiffFromEditScript old new (getEditScriptBy eq old new)  -- | Diff two 'Vector's with grouped results-getGroupedVectorDiff :: Eq a => Vector a -> Vector a -> Vector (Diff (Vector a))+getGroupedVectorDiff :: (Eq a) => Vector a -> Vector a -> Vector (Diff (Vector a)) getGroupedVectorDiff = getGroupedVectorDiffBy (==)  -- | Diff two 'Vector's with grouped results using a custom equality operator@@ -138,7 +142,7 @@ getGroupedVectorDiffBy eq old new = computeGroupedDiffFromEditScript old new (getEditScriptBy eq old new)  -- | Compute the edit script to turn a given 'Vector' into the second given 'Vector'-getEditScript :: forall a. Eq a => Vector a -> Vector a -> Vector Edit+getEditScript :: forall a. (Eq a) => Vector a -> Vector a -> Vector Edit getEditScript = getEditScriptBy (==)  -- | Compute the edit script to turn a given 'Vector' into the second given 'Vector' with a custom equality relation@@ -475,18 +479,18 @@ data Edit   = -- | Delete from the old vector     Delete+      -- position in the old vector       Int-      -- ^ position in the old vector+      -- number of items to delete       Int-      -- ^ number of items to delete   | -- | Insert into the old vector     Insert+      -- position in the old vector       Int-      -- ^ position in the old vector+      -- position in the new vector       Int-      -- ^ position in the new vector+      -- number of items to insert       Int-      -- ^ number of items to insert   deriving (Show, Eq, Ord)  oldPosition :: Edit -> Int@@ -508,13 +512,13 @@ sliceIx start end = V.slice start (end - start)  -- | Short-circuiting monadic (&&)-(&&.) :: Applicative m => Bool -> m Bool -> m Bool+(&&.) :: (Applicative m) => Bool -> m Bool -> m Bool (&&.) b1 mkB2 = do   if b1     then mkB2     else pure False -forUntilJust :: Monad m => [a] -> (a -> m (Maybe b)) -> m (Maybe b)+forUntilJust :: (Monad m) => [a] -> (a -> m (Maybe b)) -> m (Maybe b) forUntilJust [] _ = pure Nothing forUntilJust (a : rest) func = do   mRes <- func a