Giter VIP home page Giter VIP logo

Comments (3)

judah avatar judah commented on May 22, 2024

It sounds reasonable to annotate the typeclass instances of HasLens' that proto-lens generates. For example: https://github.com/google/proto-lens/blob/master/proto-lens/src/Proto/Google/Protobuf/Descriptor.hs#L59

To control that this happens only in haskell-indexer mode: like the C++ backend, you can pass extra colon-separate arguments to --haskell_out=BLAH when invoking protoc, and just teach protoc-gen-haskell to parse them correctly. As an example in proto-lens: https://github.com/google/proto-lens/blob/master/bootstrap.hs#L30

The hardest part, I think, will be getting the locations of individual declarations within the Haskell program...you need to tie proto names to specific lines/columns within the *.hs file, right? I'm not sure how to accomplish that with Text.PrettyPrint (which is what haskell-src-exts uses)...

One option is to generate the Haskell file, then parse it again with haskell-src-exts and walk the syntax tree (annotated with SrcSpanInfo, I think) to find all declarations that, for example, look like instance HasLens' .... That approach seems a little fragile, though.

from proto-lens.

robinp avatar robinp commented on May 22, 2024

from proto-lens.

robinp avatar robinp commented on May 22, 2024

On in-source annotation vs side-channel file: If we would do in-source annotation, the annotations would likely need to be there regardless of Kythe running or not - otherwise the source code would be different when indexed by Kythe and when users looking at them, leading to differences in source locations etc.

The C++ proto code generator avoids normal compile bloat by guarding the include of the metadata source with a kythe flag. But for Haskell this would mean unnecessary CPP usage.

Other generators seem to rely on some kind of side-channel piping, connecting the above mentioned proto info with some qualified names. If we wanted to go this route, we could emit a stable qualified name, for example name of generated module + instance name, that the indexer could recognize uniquely.

from proto-lens.

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.