Comments (3)
I'd be willing to take a crack at this if you can provide some pointers on where to start. I was just looking at printStringAtMaybeAnnThen
, but it appears that's too late in the pipeline.
from ghc-exactprint.
I think in the Language.Haskell.GHC.ExactPrint.Print
module would need modification so that if it looks up an annotation and it is not there it uses an alternate default version.
The problem is that a lot of annotations are optional as a given datatype can appear in multiple roles in the AST, so simply doing a default on every possible annotation via a separate lookup would not work. There would have to be a degree of context awareness.
So running a separate pass on the unannotated AST to add the appropriate defaults might be a simpler process, which would then be another interpreter over AnnotationF, doing something similar to the Delta
one but using built-in knowledge to use defaults.
Or, as @mpickering suggested, the simplest might be to just use the GHC pretty-printer, and then parse it using ghc-exactprint to get a fully annotated AST which can be spliced into the original. Of course there is still an open ticket on GHC (https://ghc.haskell.org/trac/ghc/ticket/3384) to verify that the output of the GHC pretty-printer is in fact a faithful representation of the original. i.e. that parsing the pretty-printer output yields the same AST.
This is just an initial brain dump, sorry if it is a bit incoherent.
from ghc-exactprint.
This feature exists in current master, via addAnnotationsForPretty
from ghc-exactprint.
Related Issues (20)
- 1.3.0 is not buildable with ghc <9.2 HOT 1
- Hackage revisions with upper bounds on ghc package HOT 1
- Build failure with GHC 9.4.1 HOT 7
- For exactprint 1.5.0 / ghc-9.2.5, `makeDeltaAst'` seems to just break things
- balanceCommentsList makes a mess of relative positions
- Missing match for HsType: HsDocTy HOT 1
- Missing match for IE HOT 1
- ghc-9.8.1 build failure HOT 4
- No instance for ‘MonadTrans TransformT’ HOT 3
- Usage examples? HOT 14
- ParseResult is a different type after 8.10 HOT 1
- parseModuleFromString seems to use unhelpful dflags HOT 1
- exactPrinted comments seem to gain additional carriage returns on Windows
- addAnnotationsForPretty breaks layout HOT 5
- Parse/Print roundtrip loses shebang unless file path is in the form of "dir/file.hs"
- Migrate to ghc-lib HOT 2
- Release 0.6.3.3 HOT 3
- Using `ghc-paths` makes downstream executables non portable HOT 4
- Can DeltaPos of the first pattern not depend on the position of "case"? HOT 2
- Support GHC 9.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ghc-exactprint.