mirror of
https://github.com/github/semantic.git
synced 2024-12-19 12:51:52 +03:00
🔥 decorateParser.
This commit is contained in:
parent
cc0850ae43
commit
cea38b06f3
@ -117,10 +117,6 @@ readAndTranscodeFile path = do
|
||||
-- | A function computing a value to decorate terms with. This can be used to cache synthesized attributes on terms.
|
||||
type TermDecorator f fields field = CofreeF f (Record fields) (Record (field ': fields)) -> field
|
||||
|
||||
-- | Decorate the 'Term's produced by a 'Parser' using a function to compute the annotation values at every node.
|
||||
decorateParser :: Functor f => TermDecorator f fields field -> Parser f (Record fields) -> Parser f (Record (field ': fields))
|
||||
decorateParser decorator = (fmap (decorateTerm decorator) .)
|
||||
|
||||
-- | Decorate a 'Term' using a function to compute the annotation values at every node.
|
||||
decorateTerm :: Functor f => TermDecorator f fields field -> Cofree f (Record fields) -> Cofree f (Record (field ': fields))
|
||||
decorateTerm decorator = cata $ \ c -> cofree ((decorator (extract <$> c) .: headF c) :< tailF c)
|
||||
|
Loading…
Reference in New Issue
Block a user