Haskell: highlighting promoted types

Issue #820 closed
Anonymous created an issue

GHC DataKinds extension introduces new syntax for data constructors promoted to type level. A type name can now include a single quote in the beginning, see: http://www.haskell.org/ghc/docs/latest/html/users_guide/promotion.html#promotion-syntax Also, GHC TypeFamilies extension introduces "family" keyword which isn't highlighted yet. example: http://pygments.org/demo/58336/

Comments (6)

  1. Sandy Maguire

    I have a patch for the promoted operators:

    diff -r 7941677dc77d pygments/lexers/haskell.py
    --- a/pygments/lexers/haskell.py        Mon Mar 13 19:16:03 2017 +0000
    +++ b/pygments/lexers/haskell.py        Sat Sep 08 15:27:18 2018 -0400
    @@ -66,6 +66,7 @@
                 (r"(')[" + uni.Lu + r"][\w\']*", Keyword.Type),
                 (r"(')\[[^\]]*\]", Keyword.Type),  # tuples and lists get special treatment in GHC
                 (r"(')\([^)]*\)", Keyword.Type),  # ..
    +            (r"(')[:!#$%&*+.\\/<=>?@^|~-]+", Keyword.Type),  # promoted type operators
                 #  Operators
                 (r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function),  # lambda operator
                 (r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word),  # specials
    diff -r 7941677dc77d tests/examplefiles/example.hs
    --- a/tests/examplefiles/example.hs     Mon Mar 13 19:16:03 2017 +0000
    +++ b/tests/examplefiles/example.hs     Sat Sep 08 15:27:18 2018 -0400
    @@ -39,3 +39,7 @@
     type IntChar = '[Int, Char]
     type Falsy = 'False
     type Falsy = '(10, 20, 30)
    +type EmptyList = '[]
    +type TypeCons = 1 ': '[]
    +type Times = 1 '* 2
    
  2. Log in to comment