Skip to content
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

haskell: Properly highlight promoted data constructors #1027

Merged
merged 3 commits into from
Jun 20, 2019

Conversation

bgamari
Copy link
Contributor

@bgamari bgamari commented Nov 1, 2018

Unfortunately there is a bit of ambiguity with char literals.
For instance, the data constructor A' would be 'A' in promoted form.
This will still be highlighted as as char literal but this is the best
we can do without more context.

Unfortunately there is a bit of ambiguity with char literals.
For instance, the data constructor `A'` would be `'A'` in promoted form.
This will still be highlighted as as char literal but this is the best
we can do without more context.
@bgamari
Copy link
Contributor Author

bgamari commented Dec 12, 2018

Ping.

@pyrmont
Copy link
Contributor

pyrmont commented May 29, 2019

@bgamari Sorry it's taken so long for a response. Could you add an example of this promotion to the visual sample?

@pyrmont pyrmont added the author-action The PR has been reviewed but action by the author is needed label May 29, 2019
@pyrmont
Copy link
Contributor

pyrmont commented Jun 19, 2019

@goolord Are you able to provide a code sample (just as a comment here is fine)? I'm not familiar enough with Haskell to try to write one on my own. I'm also not sure if the regex is correct. The regex as written requires a constructor to be at least two alphanumeric characters. Shouldn't it be fine just to have one?

@goolord
Copy link

goolord commented Jun 19, 2019

i believe that's just to avoid ambiguity with char literals
img
here's some valid permutations of data constructors / promoted data constructors
since haskell is a context sensitive language, this seems like the best compromise to me. this is what i would expect in the absence of context, and it's certainly an improvement over the current highlighting

@pyrmont
Copy link
Contributor

pyrmont commented Jun 19, 2019

@goolord Thanks for the quick reply :) Makes sense.

My only comment would be that I think the regex should be the following:

rule /'[A-Z]\w+'?/, Keyword::Type  # promoted data constructor

@pyrmont pyrmont merged commit 2edea1f into rouge-ruby:master Jun 20, 2019
@pyrmont
Copy link
Contributor

pyrmont commented Jun 20, 2019

Thanks @bgamari and @goolord for your help. This has been merged!

@pyrmont pyrmont removed the author-action The PR has been reviewed but action by the author is needed label Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants