2015-11-20 00:35:06 +03:00
|
|
|
module Unified where
|
2015-11-20 01:36:32 +03:00
|
|
|
|
|
|
|
import Diff
|
2015-11-20 01:37:07 +03:00
|
|
|
import Patch
|
|
|
|
import Syntax
|
|
|
|
import Term
|
|
|
|
import Control.Monad.Free
|
2015-11-20 01:36:32 +03:00
|
|
|
|
2015-11-20 02:06:25 +03:00
|
|
|
unified :: Diff a Info -> String -> String -> String
|
2015-11-20 01:37:07 +03:00
|
|
|
unified diff before after =
|
|
|
|
iter f mapped where
|
|
|
|
mapped = fmap unifiedPatch diff
|
2015-11-20 02:06:42 +03:00
|
|
|
f (Annotated (_, Info range _) (Leaf _)) = substring range after
|
2015-11-20 01:37:07 +03:00
|
|
|
f (Annotated annotations (Indexed i)) = ""
|
|
|
|
f (Annotated annotations (Fixed f)) = ""
|
|
|
|
f (Annotated annotations (Keyed k)) = ""
|
|
|
|
unifiedPatch :: Patch (Term a annotation) -> String
|
|
|
|
unifiedPatch _ = ""
|
2015-11-20 02:08:11 +03:00
|
|
|
unifiedRange :: Range -> [(String, Maybe Range)] -> String -> String
|
|
|
|
unifiedRange _ _ _ = ""
|
2015-11-20 02:05:33 +03:00
|
|
|
|
|
|
|
substring :: Range -> String -> String
|
|
|
|
substring range = take (end range) . drop (start range)
|