:: (a -> a -> Bool) -> [a] -> [[a]] package:Diff

A version of groupBy that does not assume the argument function is transitive. This is used to partition the Diff list into segments that begin and end with matching (Both) text, with and have non-matching (First and Second) text in the middle.
let notBoth1 a b = not (a == 1 || b == 1) in

groupBy' notBoth1 [1,1,2,3,1,1,4,5,6,1]
[[1],[1,2,3,1],[1,4,5,6,1]]

groupBy notBoth1 [1,1,2,3,1,1,4,5,6,1]
[[1],[1,2,3],[1],[1,4,5,6],[1]]
In the first result the list is split anywhere there are two adjacent ones, as desired.