Skip to content

Commit

Permalink
highlight VKA + fixes to VTA
Browse files Browse the repository at this point in the history
  • Loading branch information
sheaf committed Apr 30, 2020
1 parent 5c27155 commit 080bc72
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 41 deletions.
58 changes: 31 additions & 27 deletions syntaxes/haskell.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -285,33 +285,7 @@ patterns:
- match: '\b(m?do|if|then|else|case|of)(\b(?!''))'
name: keyword.control.haskell
- include: '#numeric_literals'
- match: '(?<![\p{Ll}_\p{Lu}\p{Lt}\p{Nd}''])(@)\s*([\p{Ll}_\p{Lu}\p{Lt}\p{Nd}'']+)'
captures:
'1': {name: keyword.operator.at.haskell}
'2':
patterns:
- include: '#type_variable'
- include: '#type_constructor'
- begin: '(?<![\p{Ll}_\p{Lu}\p{Lt}\p{Nd}''])(@)\s*(\()'
beginCaptures:
'1': {name: keyword.operator.at.haskell}
'2': {name: punctuation.paren.haskell}
end: '\)'
endCaptures:
'0': {name: punctuation.paren.haskell}
name: meta.type-application.haskell
patterns:
- include: '#type_signature'
- begin: '(?<![\p{Ll}_\p{Lu}\p{Lt}\p{Nd}''])(@)\s*(\[)'
beginCaptures:
'1': {name: keyword.operator.at.haskell}
'2': {name: punctuation.brace.haskell}
end: '\]'
name: meta.type-application.haskell
endCaptures:
'0': {name: punctuation.brace.haskell}
patterns:
- include: '#type_signature'
- include: '#type_application'
- captures:
'1': {name: punctuation.definition.preprocessor.c}
comment: 'In addition to Haskell''s "native" syntax, GHC permits the C preprocessor to be run on a source file.'
Expand Down Expand Up @@ -568,6 +542,35 @@ repository:
| } # A block closed? Maybe this should also include `;`, because non-indentation based `do`
)
| ^(?!\1\s+\S|\s*$) # at least one, no-further indented, non-whitespace character. I.e. a same-level declaration/implementation
type_application:
patterns:
- begin: '(?<=\s)(@)(\()'
beginCaptures:
'1': {name: keyword.operator.at.haskell}
'2': {name: punctuation.paren.haskell}
end: '\)'
endCaptures:
'0': {name: punctuation.paren.haskell}
name: meta.type-application.haskell
patterns:
- include: '#type_signature'
- begin: '(?<=\s)(@)\s*(\[)'
beginCaptures:
'1': {name: keyword.operator.at.haskell}
'2': {name: punctuation.brace.haskell}
end: '\]'
name: meta.type-application.haskell
endCaptures:
'0': {name: punctuation.brace.haskell}
patterns:
- include: '#type_signature'
- begin: '(?<=\s)(@)(?=[\p{Ll}_\p{Lu}\p{Lt}\p{Nd}''])'
beginCaptures:
'1': {name: keyword.operator.at.haskell}
end: '[^\p{Ll}_\p{Lu}\p{Lt}\p{Nd}'']'
name: meta.type-application.haskell
patterns:
- include: '#type_signature'
type_signature:
patterns:
- match: '\(\s*\)'
Expand All @@ -580,6 +583,7 @@ repository:
- include: '#integer_literals'
- match: '(::|∷)(?![\p{S}\p{P}&&[^(),;\[\]`{}_"'']])'
name: keyword.operator.double-colon.haskell
- include: '#type_application'
- match: '(?<=[\s())\w\d]):[\p{S}\p{P}&&[^(),;\[\]`{}_"'']]+(?=[\s()\w\d])'
comment: Operator type
name: keyword.operator.custom.haskell
Expand Down
1 change: 0 additions & 1 deletion test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ticketsBroken=(
"T0072a.hs"
"T0072c.hs"
"T0071.hs"
"T0073.hs"
"T0091.hs"
"T0112.hs"
"T0121.hs"
Expand Down
26 changes: 13 additions & 13 deletions test/tickets/T0073.hs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
-- SYNTAX TEST "source.haskell" "Visible type application"

function =
let l = [] @[Int] in
let l = [] @[( Int, f [ Bool ] )] in
-- ^ meta.type-application.haskell
-- ^^^ storage.type.haskell
-- ^^^ storage.type.haskell
-- ^ variable.other.generic-type.haskell
let x = "Hello" @String in
-- ^ meta.type-application.haskell
-- ^^^^^^ storage.type.haskell
let c@(Some pattern) = undefined in
-- ^ keyword.operator.haskell
-- ^ - meta.type-application.haskell
-- ^^^^ constant.other.haskell
let g = f @(g -> String) in
let g = f @( g ([]) -> String ) in
-- ^ meta.type-application.haskell
-- ^ variable.other.generic-type.haskell
let h = k @_ @_ @Int
-- ^ ^ meta.type-application.haskell
-- ^ variable.other.generic-type.haskell
let h = k @_ @a @Int
-- ^ ^ ^ meta.type-application.haskell
let a = b @ c
-- ^ - meta.type-application.haskell
undefined


-- Visible kind application

type family TF (a :: k) ( b :: l ) :: l where
TF @_ @(l :: Nat) A = B
-- ^ ^ meta.type-application.haskell
g = f @Bool(A)
-- ^ meta.type-application.haskell
-- ^^^^ storage.type.haskell
-- ^ - storage.type.haskell
4 changes: 4 additions & 0 deletions test/tickets/T0073b.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- SYNTAX TEST "source.haskell" "Visible kind application"

type TF l = F @_ @(l :: Nat) A
-- ^ ^ meta.type-application.haskell

0 comments on commit 080bc72

Please sign in to comment.