@@ -1,9 +1,9 @@
11<?xml version="1.0" encoding="UTF-8"?>
22<syntax name="haskell">
33 <meta>
4− <name>Haskell</name>
5− <type>compiled</type>
6− <preferred-file-extension>hs</preferred-file-extension>
4+ <name>Haskell</name>
5+ <type>compiled</type>
6+ <preferred-file-extension>hs</preferred-file-extension>
77 </meta>
88
99 <detectors>
@@ -57,6 +57,7 @@
5757 <include syntax="self" collection="type-family-definition" />
5858 <include syntax="self" collection="pattern-definition" />
5959 <include syntax="self" collection="type-definition" />
60+ <!-- <include syntax="self" collection="type-annotation" /> -->
6061 <include syntax="self" collection="GADT-definition" />
6162 <include syntax="self" collection="instance" />
6263 <include syntax="self" collection="typeclass" />
@@ -65,6 +66,7 @@
6566
6667 <template-scopes>
6768 <include syntax="self" collection="Quote" />
69+ <include syntax="self" collection="comments" />
6870 </template-scopes>
6971
7072 <collections>
@@ -77,27 +79,54 @@
7779 </collection>
7880
7981 <collection name="expressions">
80− <scope name="haskell.construct.keyword.at">
81− <expression>@</expression>
82− </scope>
83− <scope name="haskell.construct.keyword.case-arrow">
84− <expression>-></expression>
85− </scope>
86− <scope name="haskell.construct.keyword.bind-arrow">
87− <expression><-</expression>
82+ <scope>
83+ <expression></expression>
8884 </scope>
89− <include syntax="self" collection="keywords" />
85+ <include syntax="self" collection="do-bind" />
9086 <include syntax="self" collection="literal" />
9187 <include syntax="self" collection="operators" />
92− <include syntax="self" collection="record-match" />
9388 <include syntax="self" collection="list" />
94− <include syntax="self" collection="view-pattern" />
9589 <include syntax="self" collection="lambda-case" />
9690 <include syntax="self" collection="lambda-head" />
97− <include syntax="self" collection="case-expression" />
98− <include syntax="self" collection="qconid" />
91+ <include syntax="self" collection="type-applications" />
92+ <include syntax="self" collection="outer-case-expression" />
9993 <include syntax="self" collection="qvarid" />
10094 <include syntax="self" collection="tuple" />
95+
96+
97+ <!-- Needed for do binds -->
98+ <!-- <include syntax="self" collection="pattern-match" /> -->
99+ </collection>
100+
101+ <collection name="pattern-match">
102+ <include syntax="self" collection="literal" />
103+ <include syntax="self" collection="tuple-match" />
104+ <!-- <include syntax="self" collection="at-pattern" /> -->
105+ <include syntax="self" collection="varid" />
106+ <include syntax="self" collection="qconid" />
107+ <include syntax="self" collection="record-match" />
108+ <include syntax="self" collection="list-pattern" />
109+ <include syntax="self" collection="view-pattern" />
110+ </collection>
111+
112+ <collection name="type-applications">
113+ <scope name="type-applications">
114+ <starts-with>
115+ <expression>(\s@)\(</expression>
116+ <capture number="1" name="haskell.keyword.operator.typeapplication" />
117+ </starts-with>
118+ <ends-with>
119+ <expression>)</expression>
120+ </ends-with>
121+ <subscopes>
122+ <include syntax="self" collection="type" />
123+ </subscopes>
124+ </scope>
125+ <scope name="type-applications-single">
126+ <expression>(@)(\w+)</expression>
127+ <capture number="1" name="haskell.keyword.operator.typeapplication" />
128+ <capture number="2" name="haskell.identifier.type" />
129+ </scope>
101130 </collection>
102131
103132 <collection name="Quote">
@@ -136,8 +165,8 @@
136165 <capture number="1" name="haskell.pattern.record.bracket" />
137166 </ends-with>
138167 <subscopes>
139− <include syntax="self" collection="comments" />
140− <include syntax="self" collection="expressions" />
168+ <include syntax="self" collection="pattern-match" />
169+ <include syntax="self" collection="varid" />
141170 <scope name="record-sep">
142171 <expression>=</expression>
143172 </scope>
@@ -159,7 +188,6 @@
159188 <capture number="1" name="haskell.pattern.record.bracket" />
160189 </ends-with>
161190 <subscopes>
162− <include syntax="self" collection="comments" />
163191 <scope name="haskell.pattern.record.wildcard">
164192 <expression>\.\.</expression>
165193 </scope>
@@ -186,12 +214,29 @@
186214 <capture number="1" name="haskell.list.bracket" />
187215 </ends-with>
188216 <subscopes>
189− <include syntax="self" collection="comments" />
190217 <include syntax="self" collection="expressions" />
191218 </subscopes>
192219 </scope>
193220 </collection>
194221
222+ <collection name="list-pattern">
223+ <symbol type="expression" />
224+ <scope name="haskell.pattern.list">
225+ <starts-with>
226+ <expression>(\[)</expression>
227+ <capture number="1" name="haskell.pattern.list.bracket" />
228+ </starts-with>
229+ <ends-with>
230+ <expression>(\])</expression>
231+ <capture number="1" name="haskell.pattern.list.bracket" />
232+ </ends-with>
233+ <subscopes>
234+ <include syntax="self" collection="pattern-match" />
235+ </subscopes>
236+ </scope>
237+ </collection>
238+
239+
195240 <collection name="view-pattern">
196241 <scope name="haskell.pattern.view">
197242 <symbol type="expression" />
@@ -208,7 +253,24 @@
208253 <scope name="haskell.pattern.view.operator.arrow">
209254 <expression>-></expression>
210255 </scope>
211− <include syntax="self" collection="expressions" />
256+ <include syntax="self" collection="pattern-match" />
257+ </subscopes>
258+ </scope>
259+ </collection>
260+
261+ <collection name="tuple-match">
262+ <symbol type="expression" />
263+ <scope name="haskell.pattern.tuple">
264+ <starts-with>
265+ <expression>(\()</expression>
266+ <capture number="1" name="haskell.pattern.tuple.bracket" />
267+ </starts-with>
268+ <ends-with>
269+ <expression>(\))</expression>
270+ <capture number="1" name="haskell.pattern.tuple.bracket" />
271+ </ends-with>
272+ <subscopes>
273+ <include syntax="self" collection="pattern-match" />
212274 </subscopes>
213275 </scope>
214276 </collection>
@@ -224,11 +286,53 @@
224286 <capture number="1" name="haskell.case.keyword.condition" />
225287 </ends-with>
226288 <subscopes anchored="true">
289+ <include syntax="self" collection="pattern-match" />
290+ </subscopes>
291+ </scope>
292+ </collection>
293+
294+ <collection name="case-match">
295+ <scope name="case-match">
296+ <starts-with>
297+ <expression>(?=((\h*)\S.*->($|\h)))</expression>
298+ </starts-with>
299+ <ends-with>
300+ <expression>-></expression>
301+ </ends-with>
302+ <subscopes anchored="true">
303+ <include syntax="self" collection="pattern-match" />
304+ </subscopes>
305+ </scope>
306+ </collection>
307+
308+ <collection name="inner-case-expressions">
309+ <scope name="inner-case-expressions">
310+ <starts-with>
311+ <expression>(?=((\h*)\S.*->($|\h)))</expression>
312+ </starts-with>
313+ <ends-with>
314+ <template>^(?!\1)(?!\2\h)(?!\s*$)</template>
315+ </ends-with>
316+ <subscopes anchored="true" skip-whitespace="false">
317+ <include syntax="self" collection="case-match" />
227318 <include syntax="self" collection="expressions" />
228319 </subscopes>
229320 </scope>
230321 </collection>
231322
323+ <collection name="outer-case-expression">
324+ <scope name="outer-case-expression">
325+ <starts-with>
326+ <expression>(?=case)</expression>
327+ </starts-with>
328+ <ends-with />
329+ <subscopes anchored="true" skip-whitespace="false">
330+ <include syntax="self" collection="case-expression" />
331+ <include syntax="self" collection="inner-case-expressions" repeat="true" />
332+ </subscopes>
333+ </scope>
334+ </collection>
335+
232336 <collection name="tuple">
233337 <symbol type="expression" />
234338 <scope name="haskell.tuple">
@@ -241,73 +345,73 @@
241345 <capture number="1" name="haskell.tuple.bracket" />
242346 </ends-with>
243347 <subscopes>
244− <include syntax="self" collection="comments" />
245348 <include syntax="self" collection="expressions" />
246349 </subscopes>
247350 </scope>
248351 </collection>
249352
250353 <collection name="typeclass">
251− <scope name="haskell.definition.class.head">
252− <symbol type="class" scope="global" name-selector="haskell.keyword.construct.class.name">
253− <context behavior="whitespace" foldable="true" />
254− </symbol>
354+ <symbol type="interface" />
355+ <scope name="haskell.definition.class">
255356 <starts-with>
256357 <expression>^(\h*)(class)($|\h)</expression>
257358 <capture number="2" name="haskell.keyword.construct.class" />
258359 </starts-with>
259− <ends-with />
260− <subscopes anchored="true">
261− <scope name="haskell.keyword.construct.class.name">
262− <starts-with>
263− <expression></expression>
264− </starts-with>
265− <ends-with>
266− <expression>(?=(where|^\s*$))</expression>
267− </ends-with>
268− <subscopes>
269− <include syntax="self" collection="comments" />
270− <include syntax="self" collection="type" />
271− </subscopes>
272− </scope>
273− <scope name="haskell.keyword.construct.where" optional="true">
360+ <ends-with>
361+ <template>^(?!\s+\1\S)(?!\s*$)</template>
362+ </ends-with>
363+ <subscopes>
364+ <scope name="haskell.keyword.construct.where">
274365 <expression>where</expression>
275366 </scope>
367+ <include syntax="self" collection="type" />
368+ <include syntax="self" collection="type-definition" />
369+ <!-- <include syntax="self" collection="type-annotation" /> -->
370+ <include syntax="self" collection="definition" />
276371 </subscopes>
277372 </scope>
278373 </collection>
279374
280375 <collection name="instance">
281376 <scope name="haskell.instance">
282− <symbol type="category" name-selector="haskell.keyword.construct.instance.name">
377+ <symbol type="category">
283378 <context behavior="whitespace" foldable="true" />
284379 </symbol>
285380 <starts-with>
286381 <expression>^(\h*)(instance)($|\h)</expression>
287382 <capture number="2" name="haskell.keyword.construct.instance" />
288383 </starts-with>
289− <ends-with />
290− <subscopes anchored="true">
291− <scope name="haskell.keyword.construct.instance.name">
384+ <ends-with>
385+ <template>^(?!\s+\1\S)(?!\s*$)</template>
386+ </ends-with>
387+ <subscopes anchored="true" skip-whitespace="false">
388+ <scope name="haskell.construct.instance.head">
292389 <starts-with>
293390 <expression></expression>
294391 </starts-with>
295392 <ends-with>
296− <expression>(?=(where|^\s*$))</expression>
393+ <expression>where</expression>
394+ <capture number="0" name="haskell.keyword.construct.where" />
297395 </ends-with>
298396 <subscopes>
299− <include syntax="self" collection="type" />
397+ <include syntax="self" collection="type" optional="true" repeat="true" />
300398 </subscopes>
301399 </scope>
302− <scope name="haskell.keyword.construct.where" optional="true">
303− <expression>where</expression>
304− </scope>
400+ <include syntax="self" collection="instance-body" />
305401 </subscopes>
306402 </scope>
307403 </collection>
308404
405+ <collection name="instance-body">
406+ <include syntax="self" collection="definition" />
407+ <include syntax="self" collection="type-definition" />
408+ </collection>
409+
309410 <collection name="type-family-definition">
310411 <scope name="haskell.definition.type-family.type">
412+ <symbol type="type" scope="global">
413+ <context behavior="subtree" foldable="false" />
414+ </symbol>
311415 <starts-with>
312416 <expression>^(\h*)(type\h+family)</expression>
313417 <capture number="2" name="haskell.keyword.construct.type-family" />
@@ -346,7 +450,6 @@
346450 <template>^(?!\s+\1\S)(?!\s*$)</template>
347451 </ends-with>
348452 <subscopes>
349− <include syntax="self" collection="comments" />
350453 <include syntax="self" collection="type" optional="true" repeat="true" />
351454 <scope>
352455 <expression>=</expression>
@@ -358,7 +461,7 @@
358461
359462 <collection name="definition">
360463 <scope name="haskell.definition.type.function">
361− <symbol type="function">
464+ <symbol type="function" scope="local">
362465 <context behavior="whitespace" foldable="true" />
363466 </symbol>
364467 <starts-with>
@@ -370,15 +473,53 @@
370473 <template>^(?!\1\3\s)(?!\s+\1\S)(?!\s*$)</template>
371474 </ends-with>
372475 <subscopes>
373− <include syntax="self" collection="comments" />
374476 <include syntax="self" collection="type-annotation" />
375477 <include syntax="self" collection="implementation" />
376478 </subscopes>
377479 </scope>
378480 </collection>
379481
482+ <collection name="do-bind">
483+ <scope name="do-bind">
484+ <symbol>
485+ <context behavior="whitespace"></context>
486+ </symbol>
487+ <starts-with>
488+ <expression>^(?=((\h*)\S.+<-($|\h)))</expression>
489+ </starts-with>
490+ <ends-with>
491+ <template>^(?!\1)(?!\2\h)(?!\s*$)</template>
492+ </ends-with>
493+ <subscopes>
494+ <include syntax="self" collection="do-pattern" />
495+ <include syntax="self" collection="expressions" />
496+ <!-- <scope name="bind-arrow">
497+ <expression><-</expression>
498+ </scope> -->
499+ </subscopes>
500+ </scope>
501+ </collection>
502+
503+ <collection name="do-pattern">
504+ <scope name="do-pattern">
505+ <starts-with>
506+ <expression>^(?=((\h*)\S.+<-($|\h)))</expression>
507+ </starts-with>
508+ <ends-with>
509+ <expression><-</expression>
510+ </ends-with>
511+ <subscopes>
512+ <include syntax="self" collection="pattern-match" />
513+ <!-- <scope name="bind-arrow">
514+ <expression><-</expression>
515+ </scope>
516+ <include syntax="self" collection="expressions" repeat="true" /> -->
517+ </subscopes>
518+ </scope>
519+ </collection>
520+
380521 <collection name="implementation">
381− <scope name="haskell.definition.type.function.implementation">
522+ <scope name="haskell.definition.type.function">
382523 <starts-with>
383524 <expression>^(\h*)(default\h+)?`?(\w(\w|')*)`?($|\h)</expression>
384525 <capture number="2" name="haskell.keyword.construct.default" />
@@ -387,8 +528,7 @@
387528 <ends-with>
388529 <template>^(?!\1\3\s)(?!\s+\1\S)(?!\s*$)</template>
389530 </ends-with>
390− <subscopes>
391− <include syntax="self" collection="comments" />
531+ <subscopes anchored="true">
392532 <include syntax="self" collection="pattern-match" optional="true" repeat="true" />
393533 <scope>
394534 <expression>=</expression>
@@ -401,7 +541,7 @@
401541 </collection>
402542
403543 <collection name="type-annotation">
404− <scope name="haskell.definition.type.function.type-signature">
544+ <scope name="haskell.definition.type.function">
405545 <starts-with>
406546 <expression>^(\h*)`?(\w(\w|')*)`?\h*::($|\h)</expression>
407547 <capture number="2" name="haskell.identifier.function" />
@@ -410,7 +550,6 @@
410550 <template>^(?!\s+\1\S)(?!\s*$)</template>
411551 </ends-with>
412552 <subscopes>
413− <include syntax="self" collection="comments" />
414553 <include syntax="self" collection="type" />
415554 </subscopes>
416555 </scope>
@@ -430,7 +569,6 @@
430569 <template>^(?!\s+\1\S)(?!\s*$)</template>
431570 </ends-with>
432571 <subscopes>
433− <include syntax="self" collection="comments" />
434572 <include syntax="self" collection="type" />
435573 </subscopes>
436574 </scope>
@@ -450,7 +588,6 @@
450588 <template>^(?!\s+\1\S)(?!\s*$)</template>
451589 </ends-with>
452590 <subscopes>
453− <include syntax="self" collection="comments" />
454591 <scope name="haskell.keyword.construct.where">
455592 <expression>where</expression>
456593 </scope>
@@ -466,16 +603,15 @@
466603 <collection name="gadt-constructor">
467604 <scope name="haskell.identifier.type.struct.data.constructor">
468605 <symbol type="constructor">
469− <context behavior="subtree" foldable="true" />
606+ <context behavior="whitespace" />
470607 </symbol>
471− <starts-with>
472− <expression>(^|=|\||^)\h+([A-Z](\w|')*)</expression>
473− <capture number="2" name="haskell.identifier.data.name" />
474− </starts-with>
475− <ends-with />
476− <subscopes anchored="true">
477− <include syntax="self" collection="record-definition" />
478− </subscopes>
608+ <expression>(^|=|\|)\h+([A-Z](\w|')*)</expression>
609+ <capture number="2" name="haskell.identifier.data.name" />
610+ </scope>
611+ <scope name="identifier.type.struct.GADT.constructor">
612+ <symbol type="constructor"></symbol>
613+ <expression>^\h+([A-Z](\w|')*)</expression>
614+ <capture number="1" name="haskell.identifier.data.name" />
479615 </scope>
480616 </collection>
481617
@@ -483,10 +619,6 @@
483619 <scope name="haskell.record.construct.deriving.keyword">
484620 <expression>deriving(\h+(newtype|stock|anyclass))?</expression>
485621 </scope>
486− <scope name="haskell.record.construct.deriving.keyword">
487− <include syntax="self" collection="comments" />
488− <expression>via</expression>
489− </scope>
490622 </collection>
491623
492624 <collection name="record-definition">
@@ -503,7 +635,6 @@
503635 <capture number="1" name="haskell.record.bracket" />
504636 </ends-with>
505637 <subscopes>
506− <include syntax="self" collection="comments" />
507638 <include syntax="self" collection="record-definition-field-name" />
508639 <include syntax="self" collection="type" />
509640 </subscopes>
@@ -535,7 +666,6 @@
535666 <expression>\)</expression>
536667 </ends-with>
537668 <subscopes>
538− <include syntax="self" collection="comments" />
539669 <scope name="haskell.construct.type.typle.comma">
540670 <expression>\,</expression>
541671 </scope>
@@ -550,7 +680,6 @@
550680 <expression>\]</expression>
551681 </ends-with>
552682 <subscopes>
553− <include syntax="self" collection="comments" />
554683 <include syntax="self" collection="type" />
555684 </subscopes>
556685 </scope>
@@ -570,7 +699,7 @@
570699 <expression>forall</expression>
571700 </scope>
572701 <scope name="haskell.identifier.type.variable">
573− <expression>(?!where)(?!=)((?!(\(|\)|\,|\!))\S)((?!(\(|\)|\,))\w)*</expression>
702+ <expression>(?!where)(?!=)((?!(\(|\)|\,|\!))\S)((?!(\(|\)|\,))\S)*</expression>
574703 </scope>
575704 </collection>
576705
@@ -585,7 +714,6 @@
585714 <template>^(?!\s+\1\S)(?!\s*$)</template>
586715 </ends-with>
587716 <subscopes>
588− <include syntax="self" collection="comments" />
589717 <scope name="haskell.keyword.construct.where">
590718 <expression>where</expression>
591719 </scope>
@@ -605,7 +733,6 @@
605733 <capture number="1" name="haskell.type-list.bracket" />
606734 </ends-with>
607735 <subscopes>
608− <include syntax="self" collection="comments" />
609736 <include syntax="self" collection="type" />
610737 </subscopes>
611738 </scope>
@@ -622,7 +749,6 @@
622749 <capture number="1" name="haskell.keyword.construct.lambda" />
623750 </ends-with>
624751 <subscopes>
625− <include syntax="self" collection="comments" />
626752 <include syntax="self" collection="pattern-match" />
627753 </subscopes>
628754 </scope>
@@ -644,7 +770,6 @@
644770 <template>^(?!\1\s*\S)(?!s*$)</template>
645771 </ends-with>
646772 <subscopes>
647− <include syntax="self" collection="comments" />
648773 <include syntax="self" collection="definition" />
649774 </subscopes>
650775 </scope>
@@ -684,12 +809,12 @@
684809
685810
686811 <collection name="strings">
687− <scope name="haskell.string.double-quoted" spell-check="true">
812+ <scope name="haskell.string.double-quoted">
688813 <starts-with>
689− <expression>"</expression>
814+ <expression>"</expression>
690815 </starts-with>
691816 <ends-with>
692− <expression>"</expression>
817+ <expression>"</expression>
693818 </ends-with>
694819 <subscopes>
695820 <scope name="haskell.string.escape-sequences">
@@ -726,7 +851,6 @@
726851 </ends-with>
727852 <subscopes>
728853 <scope name="identifier.haskell.type">
729− <symbol type="expression" />
730854 <symbol type="expression" />
731855 <expression>([A-Z](\w|')*)\h*(\(\h*\.\.\h*\))?</expression>
732856 <capture number="1" name="identifier.type" />
@@ -751,7 +875,6 @@
751875 </ends-with>
752876 <subscopes>
753877 <scope name="haskell.construct.qualified">
754− <symbol type="expression" />
755878 <expression>qualified</expression>
756879 <capture number="0" name="haskell.construct.keyword.qualified" />
757880 </scope>
@@ -769,7 +892,6 @@
769892 </ends-with>
770893 <subscopes anchored="true">
771894 <include syntax="self" collection="import-list" />
772− <symbol type="expression" />
773895 </subscopes>
774896 </scope>
775897
@@ -803,7 +925,6 @@
803925 </ends-with>
804926 <subscopes>
805927 <scope name="haskell.identifier.struct">
806− <symbol type="expression" />
807928 <symbol type="reference" scope="local" />
808929 <expression>([A-Z](\w|')*)\h*(\(\h*\.\.\h*\))?</expression>
809930 <capture number="1" name="haskell.import-list.identifier.type.name" />
@@ -817,6 +938,13 @@
817938 </scope>
818939 </collection>
819940
941+ <!-- <collection name="special">
942+ <scope>
943+ <expression>(;|,)</expression>
944+ </scope>
945+ </collection> -->
946+
947+
820948 <collection name="reservedop">
821949 <scope name="keyword.operator">
822950 <expression>(\.\.|:|::|=|\\|\||<-|->|@|~|=>)</expression>
@@ -824,11 +952,10 @@
824952 </collection>
825953
826954 <collection name="keywords">
827− <scope name="haskell.keyword.self">
955+ <scope name="haskell.keyword.modifier">
828956 <symbol type="keyword" />
829957 <strings>
830958 <string>do</string>
831− <string>mdo</string>
832959 <string>in</string>
833960 <string>infix</string>
834961 <string>infixl</string>
@@ -866,18 +993,20 @@
866993 <strings>
867994 <string>undefined</string>
868995 <string>_</string>
869− <string>@</string>
870996 </strings>
871997 </scope>
872998 </collection>
873999
8741000 <collection name="comments">
8751001 <scope name="haskell.comment.single" spell-check="true">
876− <symbol type="comment" />
877− <expression> --.*$</expression>
1002+ <starts-with>
1003+ <expression>--</expression>
1004+ </starts-with>
1005+ <ends-with>
1006+ <expression>$</expression>
1007+ </ends-with>
8781008 </scope>
8791009 <scope name="haskell.comment.block" spell-check="true">
880− <symbol type="comment" />
8811010 <starts-with>
8821011 <expression>{-</expression>
8831012 </starts-with>