Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Annotated ast
- astA :: Annotated ast -> ast
- annsA :: Annotated ast -> Anns
- seedA :: Annotated ast -> Int
- type AnnotatedHsDecl = Annotated (LHsDecl GhcPs)
- type AnnotatedHsExpr = Annotated (LHsExpr GhcPs)
- type AnnotatedHsType = Annotated (LHsType GhcPs)
- type AnnotatedImport = Annotated (LImportDecl GhcPs)
- type AnnotatedImports = Annotated [LImportDecl GhcPs]
- type AnnotatedModule = Annotated (Located HsModule)
- type AnnotatedPat = Annotated (Located (Pat GhcPs))
- type AnnotatedStmt = Annotated (LStmt GhcPs (LHsExpr GhcPs))
- pruneA :: (Data ast, Monad m) => ast -> TransformT m (Annotated ast)
- graftA :: (Data ast, Monad m) => Annotated ast -> TransformT m ast
- transformA :: Monad m => Annotated ast1 -> (ast1 -> TransformT m ast2) -> m (Annotated ast2)
- trimA :: Data ast => Annotated ast -> Annotated ast
- printA :: Annotate ast => Annotated (Located ast) -> String
- unsafeMkA :: ast -> Anns -> Int -> Annotated ast
Annotated
Annotated
packages an AST fragment with the annotations necessary to
exactPrint
or transform
that AST.
Instances
Functor Annotated Source # | |
Foldable Annotated Source # | |
Defined in Retrie.ExactPrint.Annotated fold :: Monoid m => Annotated m -> m # foldMap :: Monoid m => (a -> m) -> Annotated a -> m # foldMap' :: Monoid m => (a -> m) -> Annotated a -> m # foldr :: (a -> b -> b) -> b -> Annotated a -> b # foldr' :: (a -> b -> b) -> b -> Annotated a -> b # foldl :: (b -> a -> b) -> b -> Annotated a -> b # foldl' :: (b -> a -> b) -> b -> Annotated a -> b # foldr1 :: (a -> a -> a) -> Annotated a -> a # foldl1 :: (a -> a -> a) -> Annotated a -> a # toList :: Annotated a -> [a] # length :: Annotated a -> Int # elem :: Eq a => a -> Annotated a -> Bool # maximum :: Ord a => Annotated a -> a # minimum :: Ord a => Annotated a -> a # | |
Traversable Annotated Source # | |
Defined in Retrie.ExactPrint.Annotated | |
(Data ast, Monoid ast) => Semigroup (Annotated ast) Source # | |
(Data ast, Monoid ast) => Monoid (Annotated ast) Source # | |
Default ast => Default (Annotated ast) Source # | |
Defined in Retrie.ExactPrint.Annotated |
seedA :: Annotated ast -> Int Source #
Name supply used by ghc-exactprint to generate unique locations.
Synonyms
type AnnotatedImport = Annotated (LImportDecl GhcPs) Source #
type AnnotatedImports = Annotated [LImportDecl GhcPs] Source #
Operations
graftA :: (Data ast, Monad m) => Annotated ast -> TransformT m ast Source #
Graft an Annotated
thing into the current transformation.
The resulting AST will have proper annotations within the TransformT
computation. For example:
mkDeclList :: IO (Annotated [LHsDecl GhcPs]) mkDeclList = do ad1 <- parseDecl "myId :: a -> a" ad2 <- parseDecl "myId x = x" transformA ad1 $ \ d1 -> do d2 <- graftA ad2 return [d1, d2]
transformA :: Monad m => Annotated ast1 -> (ast1 -> TransformT m ast2) -> m (Annotated ast2) Source #
Transform an Annotated
thing.
trimA :: Data ast => Annotated ast -> Annotated ast Source #
Trim the annotation data to only include annotations for ast
.
(Usually, the annotation data is a superset of what is necessary.)
Also freshens all source locations, so filename information
in annotation keys is discarded.
Note: not commonly needed, but useful if you want to inspect the annotation data directly and don't want to wade through a mountain of output.