Pegue duas listas e produza uma 3 tupla de seu prefixo comum e respectivos sufixos (se houver):
sharePrefix :: Eq a => [a] -> [a] -> ([a], [a], [a])
sharePrefix l1 l2 = let
prefix = map fst $ takeWhile (uncurry (==)) $ zip l1 l2
f = drop $ length prefix
in
(prefix, f l1, f l2)
Por exemplo:
*Main> sharePrefix "Hello, there" "Hello, everybody"
("Hello, ","there","everybody")
*Main> sharePrefix "What's going on?" "This example has no prefix."
("","What's going on?","This example has no prefix.")
*Main> sharePrefix "Badger" "Badger"
("Badger","","")