-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dhall-docs): add jump-to-definition support for record-like expressions #1991
Conversation
63d94fd
to
9457a9e
Compare
dhall-docs/tasty/data/package/JumpToRecordFieldWhenVarIsOfRecordTypeTransitivity.dhall
Outdated
Show resolved
Hide resolved
dhall-docs/tasty/data/package/JumpToRecordFieldWhenVarIsAnnotatedWithRecordType.dhall
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@german1608, can you show us some docs that show off the new features?
I have a few comments on the changes to dhall
for now. I'm not done with the parser changes yet. I think it would be good if @Gabriel439 would take a closer look at these too.
|
||
data RecursiveType a = RecursiveType (RecursiveType a) | ||
newtype RecursiveType a = RecursiveType (RecursiveType a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that this was changed by stylish-haskell
?!
@Gabriel439, could you check that this is OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed that manually, I have a TOC that males me change to newtype when possible :) I can rollback the change, though
I'm unable to provide specific examples right now since I'm not home, but you can check the generated docs for the test package and the prelude. renderAs on Prelude/JSON has a lot of stuff |
d922d46
to
33700b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In https://hydra.dhall-lang.org/build/69960/download/1/docs/JSON/renderAs.dhall.html I noticed that every single label in a record literal seems to be highlighted. But when I hover over these or click them, nothing interesting happens. What's the reason for highlighting these labels?
That is because the implementation doesn't recognize where a record (literal or type) is stored and in any case it renders the highlight. On this moment, we recognize when a record literal has been bound to a let binding and when a lambda name is of record-type, but the rest of the cases are not handled. I guess that we could remove the highlight on unused names, although when handling imported names (as I explained here) it would get messy. Something that a couple of tests doesn't solve. |
I'll be quite bussy today, so I'll address remaining comments this night. |
OK. Currently it seems to me that there's not much point in highlighting things that don't offer more information in the same view. So when a label in one file is only used in other files, I think it's probably not worth highlighting in the first file. Maybe this issue could also be addressed by using a more sophisticated highlighting approach that uses different visual cues instead of the current one-size-fits-all design with the underlining. I'm not sure. I noticed that some types in the index pages also contain highlighting, e.g. in https://hydra.dhall-lang.org/build/70067/download/1/docs/List/index.html. Can these labels be jumped to from anywhere? |
I see. Then let me do some work to remove the unused highlights. It shouldn't be difficult |
@sjakobi Alright, I've applied your suggestions and I removed the highlighting on unused names. Note that unused let-bindings are not highlighted as well. Check this test case A thing that I'd like to do is to rename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from a few more wibbles.
Great job, @german1608! 👍
whitespaces is preserved now... * Between a label and a colon or equal sign * Between a colon or equal sign and an expression
229842a
to
357d7c8
Compare
Thanks for your good reviews! |
(this is a quite big PR, please read the full description of this PR before reviewing the code)
Summary
This PR adds JTD support for record-like expressions.
dhall-docs
now tries to infer (really simple, not likeDhall.TypeCheck
does, for example) the type of a dhall expression. As a result of this, the JTD-related features on record-like expressions are:JumpToRecordFieldWhenVarIsOfRecordTypeDeep
test case);dhall-docs
is able to keep the inferred type in a transitivity chain.You can check the written test cases to see more specific uses, and also you can suggest more test cases as well.
How to review this
This work is divided into two parts:
FieldAccess
data-type for preserving whitespace onField
expressiondot-syntax
labels, which is documented in theRecordField
haddockField
fragments
:DhallType
ADT to aim a simple type-inference algorithm.Writer [SourceCodeFragment] DhallType
. Generating[SourceCodeFragment]
for an expression will return the inferred 'DhallType'The part 1 generates a lot of noise on the PR, but I was modifying the parser as I was developing record-JTD since some changes were really specific for
dhall-docs
. If you need to, I can split (not so easy, though) thedhall
work in a separate PR that should be merged before this one.