1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 15:35:14 +03:00

Refactor to remove guard clause

This commit is contained in:
Matt Diephouse 2016-01-12 10:34:17 -05:00
parent 1cb83b4ea6
commit 0ca0b4d453

View File

@ -73,11 +73,12 @@ replaceLeavesWithWordBranches :: Source Char -> Term T.Text Info -> Term T.Text
replaceLeavesWithWordBranches source = replaceIn
where
replaceIn (info@(Info range categories) :< syntax) = info :< case syntax of
Leaf _ | ranges <- rangesAndWordsFrom (start range) (toList $ slice range source), length ranges > 1 -> Indexed $ makeLeaf categories <$> ranges
Leaf _ ->
let ranges = rangesAndWordsFrom (start range) (toList $ slice range source) in
if length ranges > 1 then Indexed $ makeLeaf categories <$> ranges else syntax
Indexed i -> Indexed $ replaceIn <$> i
Fixed f -> Fixed $ replaceIn <$> f
Keyed k -> Keyed $ replaceIn <$> k
_ -> syntax
makeLeaf categories (range, substring) = Info range categories :< Leaf (T.pack substring)
readAndTranscodeFile :: FilePath -> IO (Source Char)