From 96c728a9ca139c78b4bea837a2dfd251fbb0098b Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 15 Jul 2016 17:31:19 -0400 Subject: [PATCH] Add a function to decorate a term with the assistance of a decorating function. --- src/Diffing.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Diffing.hs b/src/Diffing.hs index d79ad2354..afc49c5d8 100644 --- a/src/Diffing.hs +++ b/src/Diffing.hs @@ -77,6 +77,9 @@ readAndTranscodeFile path = do text <- B1.readFile path transcode text +decorateTerm :: Functor f => (CofreeF f (Record fields) (Record (field ': fields)) -> field) -> Cofree f (Record fields) -> Cofree f (Record (field ': fields)) +decorateTerm decorator = cata $ \ c -> cofree ((decorator (extract <$> c) .: headF c) :< tailF c) + -- | Given a parser and renderer, diff two sources and return the rendered -- | result. -- | Returns the rendered result strictly, so it's always fully evaluated