You are given a diff between the lines of two text files.
The task is to match up line numbers in the first file with the corresponding line numbers in the second file. If this is not possible (a line has been deleted from the first file), then output a pair of lines which represent the range between which the line could land.
data Diff = First String | Second String | Both String
data Result = Exact Int | Range Int Int
mapLines :: [Diff] -> Int -> Result
mapLines diff line = _
File 1 (with line numbers):
0: a
1: b
2: c
3: d
4: y
5: z
File 2:
0: a
1: e
2: b
3: f
4: g
5: y
6: z
Diff:
Both "a"
Second "e"
Both "b"
First "c"
First "d"
Second "f"
Second "g"
Both "y"
Both "z"
Output:
0 -> 0
1 -> 2
2 -> (2,5)
3 -> (2,5)
4 -> 5
5 -> 6