Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Comment relocation for pretty-printing comments correctly.
HIndent gathers all comments above a function, an import, a module declaration, etc. For example, HIndent formats the following code
f :: Int f = 1 -- A comment between f and g -- Another comment between f and g g :: Int g = 2
to
f :: Int f = 1 -- A comment between f and g -- Another comment between f and g g :: Int g = 2
AST nodes must have the information of which comments are above, on the
same line, and below. However, AST nodes generated by a parser of
'ghc-lib-parser' only contain comments after them. relocateComments
is
defined to solve the problem.
Synopsis
- relocateComments :: HsModule -> [LEpaComment] -> HsModule
Documentation
relocateComments :: HsModule -> [LEpaComment] -> HsModule Source #
This function collects all comments from the passed HsModule
, and
modifies all EpAnn
s so that all EpAnn
s have EpaCommentsBalanced
s.