Code Monkey home page Code Monkey logo

Comments (2)

robinp avatar robinp commented on May 28, 2024

I added some comments on the slightly related #19 .

A quick summary of the current state after quickly checking https://github.com/google/haskell-indexer/blob/master/kythe-verification/testdata/basic/RecordReadRef.hs - correct me if it is wrong:

  1. now a non-literal deconstruction like bar (Foo a _) = ... will only emit a binding for a, and connect the usages of a to it. There isn't any edge going from either the binding span or the ref spans to the field. (this is why @blackgnezdo opened the issue).

  2. explicitly named deconstruction like bar Foo { x = a } = ... will connect x to the field binding. Usages of a won't be listed in the backrefs for field x.

  3. punned deconstruction like bar Foo {x} won't introduce a local binding (?), both the pattern and the usages will directly reference the field binding. Which is a bit odd highlight-wise and semantically (say, all x refs in the file are hilit even when hovering a local usage in a single function?), but at least brings the usages in the backref.

  4. For non-record constructor data Bar = Bar Int, not sure - maybe we don't even emit a field decl at the span of Int (?), so implicit matches don't even have the target to reference.

IMO, a user generally wants to see how a field is used in a specific context when looking through the backreferences. The various cases are:

  • current punning refs in (3) are not semantically nice, but bring the backref

  • for (1), (2) and (4), adding an edge from the pattern-matched name to the field would bring them in the backrefs, but if the pattern name would differ from the field name, the listing could look odd (the UI can solve this by bolding the reference in the listed line to resolve ambiguity)

As a unified solution, my gut feeling is that a local usage of a deconstructed var should directly reference both the local binding and the generic field binding in the data definition.

from haskell-indexer.

robinp avatar robinp commented on May 28, 2024

See discussion in kythe/kythe#3934 - TLDR the local binding should bind a variable/import node (maybe the subkind is not important, could be left or be field as well?), which should have an aliases edge towards the generic field binding. The index preprocessor (with appropriate config) will merge the backrefs for the local usage into the field's usage.

/cc @zrlk to verify I understand correctly

from haskell-indexer.

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.