mirror of
https://github.com/github/semantic.git
synced 2024-11-28 01:47:01 +03:00
Infix fmap for reduced chaff.
This commit is contained in:
parent
d574443969
commit
0969736753
@ -26,14 +26,14 @@ split :: Diff a Info -> String -> String -> IO ByteString
|
||||
split _ _ _ = return mempty
|
||||
|
||||
splitDiff :: Diff a Info -> String -> String -> (Maybe (HTML, Range), Maybe (HTML, Range))
|
||||
splitDiff diff before after = iter toElements $ fmap (splitPatch before after) diff
|
||||
splitDiff diff before after = iter toElements $ splitPatch before after <$> diff
|
||||
where
|
||||
toElements (Annotated (left, right) (Leaf _)) = (Just $ leafToElement before left, Just $ leafToElement after right)
|
||||
|
||||
leafToElement source (Info range _ categories) = (Span (classify categories) $ substring range source, range)
|
||||
|
||||
splitPatch :: String -> String -> Patch (Term a Info) -> (Maybe (HTML, Range), Maybe (HTML, Range))
|
||||
splitPatch before after patch = (fmap (splitTerm before) $ Patch.before patch, fmap (splitTerm after) $ Patch.after patch)
|
||||
splitPatch before after patch = (splitTerm before <$> Patch.before patch, splitTerm after <$> Patch.after patch)
|
||||
|
||||
splitTerm :: String -> Term a Info -> (HTML, Range)
|
||||
splitTerm source term = cata toElement term where
|
||||
|
Loading…
Reference in New Issue
Block a user