Skip to content

gjaldon/simple-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Diff

Description

Simple Diff is a pure OCaml implementation of a diffing algorithm ported from https://github.com/paulgb/simplediff.

Usage

opam install simple-diff

Below is some example usage in top/utop:

let old_lines = [| "I"; "really"; "like"; "icecream" |]
let new_lines = [| "I"; "do"; "not"; "like"; "icecream" |]

module Diff = Simple_diff.Make(String);;
open Diff;;

get_diff old_lines new_lines;;

#=> [
  Equal [| "I" |];
  Deleted [| "really" |];
  Added [| "do"; "not" |];
  Equal [| "like"; "icecream" |]
]

As displayed above, Simple Diff exposes a Simple_diff.Make functor which accepts a module that implements the Simple_diff.Comparable interface (check out the docs for the interface). This makes Simple_diff.S.get_diff work with lists of elements of whatever you type you want (as long as interface is followed).