Module documentation for 0.5.3.0
Using the API Annotations available from GHC 7.10.2, this library provides a means to round trip any code that can be compiled by GHC, currently excluding lhs files.
It does this with a phased approach
Delta - converts GHC API Annotations into relative offsets, indexed by SrcSpan
Transform - functions to facilitate changes to the AST, adjusting the annotations generated in the Delta phase to suit the changes.
Print - converts an AST and its annotations to properly formatted source text.
Pretty - adds annotations to an AST (fragment) so that the output can be parsed back to the same AST.
Note: requires GHC 7.10.2 or later
* Relax base constraints so tests can configure with GHC 8.4.1
* Support GHC 8.4 alpha2
* Include test examples for GHC 8.2
* Fix parseModuleFromString to correctly handle the sheband case (@lspitzner)
* Support GHC 8.2.1
* Support GHC 8.2 (rc2)
* Fix bug roundtripping optional semicolons on if statements.
* Support GHC 8.0.2
* Correct the logic around RigidLayout to function as originally
* Introduce Pretty module to add default annotations to a bare AST
fragment, so that it can be printed correctly via exactprint. In
this case, "correct" is defined as generating the same AST if
parsed again, it may not be beautiful layout.
* Expose some additional internal parsing options (@lspitzner)
* Remove additional files from release tarball
* Move annotations from the `RdrName` to `HsVar` and `PatVar` for
* Fix haddocks for GHC 8.0 (@phadej)
* Add test files for ghc710-only to dist tarball (#41)
* Support for GHC 8.0.1
* Add graftT to the Transform module, courtesy of @xich
* Add semi-pure parsing function, courtesy of @lspitzner
* Fix a bug (#34) where quasiquote values would not roundtrip.
* Add new options to enable "rigid" layout rules. This makes the
annotations more rigid in the sense that if you move AST fragments around
it is more likely that their internal components will remain in the same
position relative to each other.
* Fix a bug where files failed to parse if the file started with comments.
* Fix a bug where "[e||" was turned into "[||"
* Fix round tripping of arrow notation using ">-" and ">>-".
* Revert removing cast from markLocated until further inspection in HaRe.
* Rework HasDecls so that there are only instances for which it is
idempotent. Provide functions for managing an LHsBind which is not
idempotent, and performing general transformations on an AST
* Manage LHsDecl instances so that the Annotation always attaches
to the wrapped item, so that they can be seamlessly used in a top
level (wrapped) or local (unwrapped) context.
* Tweak transformations based on HaRe integration.
* This release supports the HaRe 8.0 release, which finally works
with GHC 7.10.2
* Rename `exactPrintWithAnns` to `exactPrint`. This will possibly
break earlier client libraries, but is a simple rename.
* Bring in semanticPrintM which allows wrapper functions to be
provided for the generated output, for use when emitting e.g. HTML
marked up source.
* Add missing test files to sdist, closes #23
* Mark LHS at the beginning of HsCase and HsIf expressions
* Mark trailing semi colons on ANN pragmas
* Correctly mark trailing semi colons distinctly from internal semicolons
* setPrecedingLinesDecl applies the setting to both the Decl and
the item wrapped in the Decl.
Substantial rework to manage changes introduced in GHC 7.10.2 rc2
Simplification of the core Annotation data type coupled with
simplification of the various phases, by @mpickering.
Introduction of initial Transform functions, driven by the needs
of HaRe  and apply-refact  for applying hlint hints. Both of
these are currently works in progress, and this module is likely
to change substantially in future releases.
Support for processing files making use of CPP.
This release contains a major rewrite of all internal modules.
The external interface has also changed significantly. A description is
# Top-level changes
The most notable change is that the common structor of the modules known as
`ExactPrint` and `Annotate` has been factored out into a common module
(`Annotate`). The aforementioned modules are now known as `Delta` and
`Print` and contain functions to interpret this common structure.
The top level module `ExactPrint` now just reexports a consistent interface
from the base modules.
Introduced a new module `Lookup` which contains a mapping from AnnKeywordId
to their String representation.
# Internal Changes
`Annotate` contains all the information about which annotations appear on
each AST element. This is achieved by building up a syntax tree (using a
free monad) which can then be interpreted by programs requiring access to
# Layout compensation
The method which compensates for layout rules has been clarified.
1. When the Layout Flag is activated in `Annotate`, we mark
the current column as the start of the layout block.
2. This is important when we move to a new line. We take the offset at
that current point to be the baseline and calculate the correct next
position based on this.
3. This method is very general as one can think of a entire source file as
obeying layout rules where the offset is equal to zero.
Handles indentation when the AST is edited
Major rework of internal monads by @mpickering
Update cabal to prevent building with GHC 7.70,thanks @peti
Initial release, for GHC 7.10 RC 2