1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00
semantic/src/Unified.hs

24 lines
722 B
Haskell
Raw Normal View History

2015-11-20 00:35:06 +03:00
module Unified where
2015-11-20 01:36:32 +03:00
import Diff
import Patch
import Syntax
import Term
import Control.Monad.Free
2015-11-20 01:36:32 +03:00
unified :: Diff a Info -> String -> String -> String
unified diff before after =
iter f mapped where
mapped = fmap unifiedPatch diff
f (Annotated (_, Info range _) (Leaf _)) = substring range after
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)