Package

purescript-diff-compare

Repository
shamansir/purescript-diff-compare
License
BSD-3-Clause
Uploaded by
pacchettibotti
Published on
2026-01-04T12:51:26Z

Extension for comparing large amounts of text in PureScript, e.g. in tests

Provides nice output for a large blocks of text, with several ways of configuration.

For example, I use it with purescript-spec like this:

shouldEqual :: forall m. MonadEffect m => MonadThrow Error m => String -> String -> m Unit
shouldEqual = Diff.compareBy (Diff.OnlyDifferent $ Diff.Limit 20)

and use this version of shouldEqual when I want to compare large bulks or text. Notice that compareBy is from Diff.Effectful module, which is made specifically to work in MonadThrow environment like purescript-spec.

Examples

Line by line

Scrolls through every line and outputs them one by one, marks equal lines as .., and if it finds a difference between the lines in two samples, it outputs the left line first and then the right line:

lineByLineComparison NoLimit "hello\nworld" "hello\nthere"

Renders:

.. hello
>> world
<< there

Only different lines

Outputs only different lines from two samples as two stacks above each other, first lines from the left and then lines from the right:

onlyDiffsComparison NoLimit "hello\nworld" "hello\nthere"

Renders:

>> world
---------------------------------------------------------------
<< there

Compare above / below

Outputs equal and different lines from two samples as two stacks above each other, first lines from the left and then lines from the right:

twoStacksComparison NoLimit "hello\nworld" "hello\nthere"

Renders:

.. hello
>> world
---------------------------------------------------------------
.. hello
<< there

And yes, instead of NoLimit you may configure how many maximum lines you want to have in the output.

Modules
Data.Text.Diff
Data.Text.Diff.Effectful
Dependencies