{ "fileTypes": ["hs", "hs-boot", "hsig"], "keyEquivalent": "^~H", "name": "haskell", "patterns": [ { "include": "#liquid_haskell" }, { "include": "#comment_like" }, { "include": "#numeric_literals" }, { "include": "#string_literal" }, { "include": "#char_literal" }, { "match": "(?[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}']*(\\.\\g)?)", "name": "entity.name.namespace.haskell" }, "pragma": { "begin": "\\{-#", "end": "#-\\}", "name": "meta.preprocessor.haskell", "patterns": [ { "begin": "(?xi) \\b(?|⇒)\n (?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']])\n", "captures": { "1": { "patterns": [ { "include": "#comment_like" }, { "include": "#type_signature" } ] }, "2": { "name": "keyword.operator.big-arrow.haskell" } } }, "data_constructor": { "match": "\\b(?\n (?:\n [\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}']*\\#*\n | \\(\\s*\n (?!--+\\))\n [\\p{S}\\p{P}&&[^(),:;\\[\\]`{}_\"']]\n [\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']]*\n \\s*\\)\n )\n (?:\\s*,\\s*\\g)?\n )\n \\s*(?)\n ((<-|←)|(=)|(-<|↢)|(-<<|⤛))\n # non-symbolic character\n ([(),;\\[\\]`{}_\"']|[^\\p{S}\\p{P}])\n )\n # Decreasing indentation:\n |(?=\\}|;) # Explicit indentation\n |^(?! # Implicit indentation: end match on newline *unless* the new line is either:\n \\1\\s+\\S # - more indented, or\n | \\s* # - starts with whitespace, followed by:\n (?: $ # - the end of the line (i.e. empty line), or\n |\\{-[^@] # - the start of a block comment, or\n |--+ # - the start of a single-line comment.\n (?![\\p{S}\\p{P}&&[^(),;\\[\\]{}`_\"']]).*$) # non-symbol\n # The double dash may not be followed by other operator characters\n # (then it would be an operator, not a comment)\n )\n" }, "adt_constructor": { "patterns": [ { "include": "#comment_like" }, { "begin": "(?x)\n (?\n \\( # Opening parenthesis\n (?:\n [^\\(\\)]* # Match non-parentheses\n | \\g # or recurse into further depth\n )*\n \\) # Closing parenthesis\n )\n )\n # Type inside balanced brackets\n | ('? # Optional promotion tick\n (?\n \\( # Opening bracket\n (?:\n [^\\[\\]]* # Match non-brackets\n | \\g # or recurse into further depth\n )*\n \\] # Closing bracket\n )\n )\n ) \n # Then either\n \\s*\n # - a symbolic infix constructor, or\n (?:(?|⇒", "name": "keyword.operator.big-arrow.haskell" }, { "include": "#string_literal" }, { "match": "'[^']'", "name": "invalid" }, { "include": "#type_application" }, { "include": "#reserved_symbol" }, { "include": "#type_operator" }, { "include": "#type_constructor" }, { "begin": "(\\()(#)", "end": "(#)(\\))", "beginCaptures": { "1": { "name": "punctuation.paren.haskell" }, "2": { "name": "keyword.operator.hash.haskell" } }, "endCaptures": { "1": { "name": "keyword.operator.hash.haskell" }, "2": { "name": "punctuation.paren.haskell" } }, "patterns": [ { "include": "#comma" }, { "include": "#type_signature" } ] }, { "begin": "(')?(\\()", "end": "(\\))", "beginCaptures": { "1": { "name": "keyword.operator.promotion.haskell" }, "2": { "name": "punctuation.paren.haskell" } }, "endCaptures": { "1": { "name": "punctuation.paren.haskell" } }, "patterns": [ { "include": "#comma" }, { "include": "#type_signature" } ] }, { "begin": "(')?(\\[)", "end": "(\\])", "beginCaptures": { "1": { "name": "keyword.operator.promotion.haskell" }, "2": { "name": "punctuation.bracket.haskell" } }, "endCaptures": { "1": { "name": "punctuation.bracket.haskell" } }, "patterns": [ { "include": "#comma" }, { "include": "#type_signature" } ] }, { "include": "#type_variable" } ] }, "double_colon": { "match": "\\s*(::|∷)(?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']])\\s*", "captures": { "1": { "name": "keyword.operator.double-colon.haskell" } } }, "start_type_signature": { "patterns": [ { "begin": "^(\\s*)(::|∷)(?![\\p{S}\\p{P}&&[^\\(,;\\[`{_\"']])\\s*", "beginCaptures": { "2": { "name": "keyword.operator.double-colon.haskell" } }, "end": "(?x)\n # End type annotation when seeing one of:\n (?=\n \\#?\\) # closing parenthesis\n |\\] # closing bracket\n |, # comma\n |(?)\n (?)\n (?|→)\n |(-<|↢)\n |(-<<|⤛)\n |(>-|⤚)\n |(>>-|⤜)\n |(∀)\n )\n (?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"'']])", "captures": { "1": { "name": "keyword.operator.double-dot.haskell" }, "2": { "name": "keyword.operator.colon.haskell" }, "3": { "name": "keyword.operator.eq.haskell" }, "4": { "name": "keyword.operator.lambda.haskell" }, "5": { "name": "keyword.operator.pipe.haskell" }, "6": { "name": "keyword.operator.arrow.left.haskell" }, "7": { "name": "keyword.operator.arrow.haskell" }, "8": { "name": "keyword.operator.arrow.left.tail.haskell" }, "9": { "name": "keyword.operator.arrow.left.tail.double.haskell" }, "10": { "name": "keyword.operator.arrow.tail.haskell" }, "11": { "name": "keyword.operator.arrow.tail.double.haskell" }, "12": { "name": "keyword.other.forall.haskell" } } }, { "match": "(?x)\n (?<=[\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\\p{S}\\p{P}&&[^\\#,;\\[`{]]) # Require closing characters\n (\\#+)\n (?![\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\\p{S}\\p{P}&&[^),;\\]`}]]) # Disallow opening character", "captures": { "1": { "name": "keyword.operator.postfix.hash.haskell" } } }, { "match": "(?x)\n (?<=[\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\\)\\}\\]]) # Require closing characters\n (@)\n (?=[\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}\\(\\[\\{]) # Require opening character", "captures": { "1": { "name": "keyword.operator.infix.tight.at.haskell" } } }, { "match": "(?x)\n (?|→)", "beginCaptures": { "1": { "name": "keyword.other.forall.haskell" } }, "endCaptures": { "1": { "name": "keyword.operator.period.haskell" }, "2": { "name": "keyword.operator.arrow.haskell" } }, "patterns": [ { "include": "#comment_like" }, { "include": "#type_variable" }, { "include": "#type_signature" } ] }, "string_literal": { "begin": "\"", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.haskell" } }, "end": "\"", "endCaptures": { "0": { "name": "punctuation.definition.string.end.haskell" } }, "name": "string.quoted.double.haskell", "patterns": [ { "match": "\\\\(NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\\"'\\&])", "name": "constant.character.escape.haskell" }, { "match": "\\\\o[0-7]+|\\\\x[0-9A-Fa-f]+|\\\\[0-9]+", "name": "constant.character.escape.octal.haskell" }, { "match": "\\\\\\^[A-Z@\\[\\]\\\\\\^_]", "name": "constant.character.escape.control.haskell" }, { "begin": "\\\\\\s", "beginCaptures": { "0": { "name": "constant.character.escape.begin.haskell" } }, "end": "\\\\", "endCaptures": { "0": { "name": "constant.character.escape.end.haskell" } }, "patterns": [ { "match": "\\S+", "name": "invalid.illegal.character-not-allowed-here.haskell" } ] } ] }, "char_literal": { "captures": { "1": { "name": "punctuation.definition.string.begin.haskell" }, "2": { "name": "constant.character.escape.haskell" }, "3": { "name": "constant.character.escape.octal.haskell" }, "4": { "name": "constant.character.escape.hexadecimal.haskell" }, "5": { "name": "constant.character.escape.control.haskell" }, "6": { "name": "punctuation.definition.string.end.haskell" } }, "match": "(?x)\n (?