From 0ca0b4d453120cc337d52f03ef77284304e4002e Mon Sep 17 00:00:00 2001 From: Matt Diephouse Date: Tue, 12 Jan 2016 10:34:17 -0500 Subject: [PATCH] Refactor to remove guard clause --- app/Main.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index bb51f607c..5ae8b87ca 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -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)