Data.Text.Diff
- Package
- purescript-diff-compare
- Repository
- shamansir/purescript-diff-compare
A module for comparing and displaying differences between text and other data structures. Provides various comparison strategies and formatting options for visualizing diffs.
#Diffable Source
class (Eq a) <= Diffable a whereA type class for values that can be converted to a string representation suitable for displaying in diff output.
Members
toDiffString :: a -> String
Instances
#DiffLine Source
data DiffLine aRepresents a line-by-line comparison result, showing the relationship between corresponding lines from two sources.
Constructors
Instances
#Comparator Source
#Whitespace Source
#ComparisonResult Source
data ComparisonResultRepresents the result of a comparison operation, indicating whether the compared items are equal or mismatched, along with the diff output if they are indeed not equal.
Constructors
ThingsEqualThingsMismatch { diff :: String }
Instances
#lineByLineComparison Source
lineByLineComparison :: Limit -> String -> String -> StringPerforms a line-by-line comparison of two strings, displaying all lines with prefixes indicating their status (equal, added, removed, or changed).
Example:
lineByLineComparison (Limit 10) "hello\nworld" "hello\nthere"
Renders:
.. hello
>> world
<< there
#onlyDiffsComparison Source
onlyDiffsComparison :: Limit -> String -> String -> StringCompares two strings line-by-line but displays only the lines that differ, showing them in two separate sections divided by a separator line.
Example:
onlyDiffsComparison (Limit 10) "hello\nworld" "hello\nthere"
Renders:
>> world
---------------------------------------------------------------
<< there
#twoStacksComparison Source
twoStacksComparison :: Limit -> String -> String -> StringCompares two strings and displays them as two parallel stacks, showing all lines (equal, added, removed, or changed) in both sections divided by a separator line.
Example:
twoStacksComparison (Limit 10) "hello\nworld" "hello\nthere"
Renders:
.. hello
>> world
---------------------------------------------------------------
.. hello
<< there
#lineByLineComparisonWP Source
lineByLineComparisonWP :: Limit -> String -> String -> StringSame as lineByLineComparison, but with whitespace characters highlighted.
#onlyDiffsComparisonWP Source
onlyDiffsComparisonWP :: Limit -> String -> String -> StringSame as onlyDiffsComparison, but with whitespace characters highlighted.
#twoStacksComparisonWP Source
twoStacksComparisonWP :: Limit -> String -> String -> StringSame as twoStacksComparison, but with whitespace characters highlighted.
#compareMany Source
compareMany :: forall f a. Eq a => Align f => f a -> f a -> f (DiffLine a)Compares two alignable structures element-by-element, producing a structure
of DiffLine results that indicate the relationship between corresponding elements.
Example:
compareMany [1, 2, 3] [1, 2, 4]
-- Returns array showing which elements are equal and which differ
#compareBy Source
compareBy :: forall t. Diffable t => Comparator -> (t -> t -> ComparisonResult)Compares two Diffable values using the specified Comparator,
returning a ComparisonResult that indicates whether they are equal or not,
along with the appropriate diff output if they differ.
#compareByWP Source
compareByWP :: forall t. Diffable t => Comparator -> (t -> t -> ComparisonResult)Compares two Diffable values using the specified Comparator,
returning a ComparisonResult that indicates whether they are equal or not,
along with the appropriate diff output, including whitespace characters, if they differ.
#compareBy_ Source
compareBy_ :: forall t. Diffable t => Whitespace -> Comparator -> (t -> t -> ComparisonResult)Compares two Diffable values using the specified Comparator and Whitespace configuration,,
returning a ComparisonResult that indicates whether they are equal or not,
along with the appropriate diff output, including whitespace characters, if they differ.