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 - highlighting of instance declaration following class declaration #1880

Closed
tmcopeland opened this issue Feb 15, 2019 · 2 comments
Closed

Comments

@tmcopeland
Copy link

Description

I found some strange behavior in Sublime's Haskell highlighting. The relevant code is from the Learn You A Haskell book, specifically the paragraph called "A yes-no typeclass".

class YesNo a where
    yesno :: a -> Bool

instance YesNo Int where
    yesno 0 = False
    yesno _ = True

instance YesNo [a] where
    yesno [] = False
    yesno _ = True

-- more instances ...

In the second code block, immediately following the typeclass declaration, the words instance and where do not highlight. This is irrespective of the order of the instance declarations. If I swap the instance declarations, the same thing happens, and additionally the expression [] does not highlight.

Oddly, this highlights as expected:

class YesNo a where
    {yesno :: a -> Bool}
-- ...

as does

class YesNo a where { yesno :: a -> Bool }
-- ...

but not if I break the line after the left brace.

class YesNo a where {
    yesno :: a -> Bool }
-- ...

It highlights as expected in gedit. See the images below.

haskell highlight 1
haskell highlight 4
haskell highlight 2
haskell highlight 3

Environment

  • Build 3176, Ubuntu 18.10, GNOME
  • No packages installed that would affect Haskell highlighting
@jacksoncooper
Copy link
Contributor

jacksoncooper commented Feb 15, 2019

This is similar to #1320. I have a patch written and will open a pull request when I'm done with the test cases. I don't think the curly braces affect the highlighting because they're ignored by the syntax file. The issue occurs because the context responsible for highlighting type signatures is not always popped when it should be.

wbond pushed a commit that referenced this issue Jul 29, 2019
…guard or an instance declaration. (#1885)

* Pop type signature context when the indentation is less than or equal to that of the function declaration.

* Add tests for #1320 and #1880.

* Don't pop type signature context when encountering a comment or a line with only whitespace.

* Update tests for #1320 and #1880.
deathaxe pushed a commit to deathaxe/sublime-packages that referenced this issue Aug 25, 2019
This PR proposes to close some already fixed issues, which were not (correctly) referenced in the fixing pull requests.

Closes sublimehq#442
Closes sublimehq#685
Closes sublimehq#691 (invalid)
Closes sublimehq#795
Closes sublimehq#807
Closes sublimehq#903
Closes sublimehq#1141
Closes sublimehq#1172
Closes sublimehq#1245
Closes sublimehq#1257
Closes sublimehq#1286
Closes sublimehq#1320
Closes sublimehq#1357
Closes sublimehq#1382 (wontfix)
Closes sublimehq#1403
Closes sublimehq#1451
Closes sublimehq#1453 (maybe)
Closes sublimehq#1472
Closes sublimehq#1495
Closes sublimehq#1540
Closes sublimehq#1542
Closes sublimehq#1565
Closes sublimehq#1576
Closes sublimehq#1625
Closes sublimehq#1880
Closes sublimehq#1898
Closes sublimehq#1940 (invalid)
@wbond
Copy link
Member

wbond commented Oct 24, 2019

This issue has been solved by a previous commit, hence it is being closed.

@wbond wbond closed this as completed Oct 24, 2019
mitranim pushed a commit to mitranim/Packages that referenced this issue Mar 25, 2022
…guard or an instance declaration. (sublimehq#1885)

* Pop type signature context when the indentation is less than or equal to that of the function declaration.

* Add tests for sublimehq#1320 and sublimehq#1880.

* Don't pop type signature context when encountering a comment or a line with only whitespace.

* Update tests for sublimehq#1320 and sublimehq#1880.
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

No branches or pull requests

3 participants