From fcff364131291078835dd4b34290556eb838adfc Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 9 Dec 2016 14:47:35 -0800 Subject: [PATCH] Remove old cata approach --- src/Renderer/SExpression.hs | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/Renderer/SExpression.hs b/src/Renderer/SExpression.hs index 1d47abdc6..f5f7d03b3 100644 --- a/src/Renderer/SExpression.hs +++ b/src/Renderer/SExpression.hs @@ -50,32 +50,3 @@ showAnnotation annotation = categoryName annotation <> " " <> showSourceSpan ann categoryName :: HasField fields Category => Record fields -> Text categoryName = toS . category - - --- TODO: Move over to FDocs about how to understand structure of Diff as well as --- the use of Free and Cofree on the different levels. -syntaxDiffToText :: HasField fields Category => Diff (Syntax Text) (Record fields) -> Text -syntaxDiffToText = cata algebra - where - algebra :: (HasField fields1 Category, HasField fields Category, Foldable t) => FreeF (TermF t (Both (Record fields1))) (Patch (Term (Syntax Text) (Record fields))) Text -> Text - algebra diff = case diff of - -- Pure nodes are patches (what's changed) - (Pure patch) -> patchFields patch - -- Free nodes are context - (Free (Join (_, annotation) :< syntax)) -> "(" <> categoryName annotation <> unwords (toList syntax) <> ")" - -patchFields :: HasField fields Category => Patch (Term (Syntax Text) (Record fields)) -> Text -patchFields patch = case patch of - Insert term -> fields "+" term - Delete term -> fields "-" term - Replace a b -> "(" <> termFields a <> "->" <> termFields b <> ")" - where - fields kind term = "(" <> kind <> termFields term <> ")" - -termFields :: HasField fields Category => Term (Syntax Text) (Record fields) -> Text -termFields = cata algebra - where - algebra :: HasField fields Category => TermF (Syntax leaf) (Record fields) Text -> Text - algebra term = case term of - (annotation :< Leaf _) -> categoryName annotation - (annotation :< syntax) -> categoryName annotation <> "(" <> unwords (toList syntax) <> ")"