Code Monkey home page Code Monkey logo

Comments (3)

gridaphobe avatar gridaphobe commented on September 24, 2024

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.

alanz avatar alanz commented on September 24, 2024

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.

alanz avatar alanz commented on September 24, 2024

This feature exists in current master, via addAnnotationsForPretty

from ghc-exactprint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.