From 63a6bf326bccabf2901438502389081060ad9297 Mon Sep 17 00:00:00 2001 From: Matt Diephouse Date: Tue, 12 Jan 2016 10:47:55 -0500 Subject: [PATCH] Use cata in replaceLeavesWithWordBranches --- app/Main.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index f66e3ef62..0f0794df4 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -70,15 +70,13 @@ printDiff arguments (aSource, bSource) (aTerm, bTerm) = case renderer arguments write rendered h = TextIO.hPutStr h rendered replaceLeavesWithWordBranches :: Source Char -> Term T.Text Info -> Term T.Text Info -replaceLeavesWithWordBranches source = replaceIn +replaceLeavesWithWordBranches source term = cata replaceIn term where - replaceIn (info :< syntax) = info :< case syntax of + replaceIn info syntax = info :< case syntax of Leaf _ | (Info range categories) <- info -> 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)