@@ -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,16 +79,7 @@
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>
88− </scope>
89− <include syntax="self" collection="keywords" />
82+ <include syntax="self" collection="do-bind" />
9083 <include syntax="self" collection="literal" />
9184 <include syntax="self" collection="operators" />
9285 <include syntax="self" collection="record-match" />
@@ -94,12 +87,33 @@
9487 <include syntax="self" collection="view-pattern" />
9588 <include syntax="self" collection="lambda-case" />
9689 <include syntax="self" collection="lambda-head" />
97− <include syntax="self" collection="case-expression" />
90+ <include syntax="self" collection="type-applications" />
91+ <include syntax="self" collection="outer-case-expression" />
9892 <include syntax="self" collection="qconid" />
9993 <include syntax="self" collection="qvarid" />
10094 <include syntax="self" collection="tuple" />
10195 </collection>
10296
97+ <collection name="type-applications">
98+ <scope name="type-applications">
99+ <starts-with>
100+ <expression>(\s@)\(</expression>
101+ <capture number="1" name="haskell.keyword.operator.typeapplication" />
102+ </starts-with>
103+ <ends-with>
104+ <expression>)</expression>
105+ </ends-with>
106+ <subscopes>
107+ <include syntax="self" collection="type" />
108+ </subscopes>
109+ </scope>
110+ <scope name="type-applications-single">
111+ <expression>(@)(\w+)</expression>
112+ <capture number="1" name="haskell.keyword.operator.typeapplication" />
113+ <capture number="2" name="haskell.identifier.type" />
114+ </scope>
115+ </collection>
116+
103117 <collection name="Quote">
104118 <scope name="haskell.quasiquote.string-template">
105119 <starts-with>
@@ -136,7 +150,6 @@
136150 <capture number="1" name="haskell.pattern.record.bracket" />
137151 </ends-with>
138152 <subscopes>
139− <include syntax="self" collection="comments" />
140153 <include syntax="self" collection="expressions" />
141154 <scope name="record-sep">
142155 <expression>=</expression>
@@ -159,7 +172,6 @@
159172 <capture number="1" name="haskell.pattern.record.bracket" />
160173 </ends-with>
161174 <subscopes>
162− <include syntax="self" collection="comments" />
163175 <scope name="haskell.pattern.record.wildcard">
164176 <expression>\.\.</expression>
165177 </scope>
@@ -186,7 +198,6 @@
186198 <capture number="1" name="haskell.list.bracket" />
187199 </ends-with>
188200 <subscopes>
189− <include syntax="self" collection="comments" />
190201 <include syntax="self" collection="expressions" />
191202 </subscopes>
192203 </scope>
@@ -229,6 +240,48 @@
229240 </scope>
230241 </collection>
231242
243+ <collection name="case-match">
244+ <scope name="case-match">
245+ <starts-with>
246+ <expression>(?=((\h*)\S.*->($|\h)))</expression>
247+ </starts-with>
248+ <ends-with>
249+ <expression>-></expression>
250+ </ends-with>
251+ <subscopes anchored="true">
252+ <include syntax="self" collection="expressions" />
253+ </subscopes>
254+ </scope>
255+ </collection>
256+
257+ <collection name="inner-case-expressions">
258+ <scope name="inner-case-expressions">
259+ <starts-with>
260+ <expression>(?=((\h*)\S.*->($|\h)))</expression>
261+ </starts-with>
262+ <ends-with>
263+ <template>^(?!\1)(?!\2\h)(?!\s*$)</template>
264+ </ends-with>
265+ <subscopes anchored="true" skip-whitespace="false">
266+ <include syntax="self" collection="case-match" />
267+ <include syntax="self" collection="expressions" />
268+ </subscopes>
269+ </scope>
270+ </collection>
271+
272+ <collection name="outer-case-expression">
273+ <scope name="outer-case-expression">
274+ <starts-with>
275+ <expression>(?=case)</expression>
276+ </starts-with>
277+ <ends-with />
278+ <subscopes anchored="true" skip-whitespace="false">
279+ <include syntax="self" collection="case-expression" />
280+ <include syntax="self" collection="inner-case-expressions" repeat="true" />
281+ </subscopes>
282+ </scope>
283+ </collection>
284+
232285 <collection name="tuple">
233286 <symbol type="expression" />
234287 <scope name="haskell.tuple">
@@ -241,73 +294,73 @@
241294 <capture number="1" name="haskell.tuple.bracket" />
242295 </ends-with>
243296 <subscopes>
244− <include syntax="self" collection="comments" />
245297 <include syntax="self" collection="expressions" />
246298 </subscopes>
247299 </scope>
248300 </collection>
249301
250302 <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>
303+ <symbol type="interface" />
304+ <scope name="haskell.definition.class">
255305 <starts-with>
256306 <expression>^(\h*)(class)($|\h)</expression>
257307 <capture number="2" name="haskell.keyword.construct.class" />
258308 </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">
309+ <ends-with>
310+ <template>^(?!\s+\1\S)(?!\s*$)</template>
311+ </ends-with>
312+ <subscopes>
313+ <scope name="haskell.keyword.construct.where">
274314 <expression>where</expression>
275315 </scope>
316+ <include syntax="self" collection="type" />
317+ <include syntax="self" collection="type-definition" />
318+ <!-- <include syntax="self" collection="type-annotation" /> -->
319+ <include syntax="self" collection="definition" />
276320 </subscopes>
277321 </scope>
278322 </collection>
279323
280324 <collection name="instance">
281325 <scope name="haskell.instance">
282− <symbol type="category" name-selector="haskell.keyword.construct.instance.name">
326+ <symbol type="category">
283327 <context behavior="whitespace" foldable="true" />
284328 </symbol>
285329 <starts-with>
286330 <expression>^(\h*)(instance)($|\h)</expression>
287331 <capture number="2" name="haskell.keyword.construct.instance" />
288332 </starts-with>
289− <ends-with />
290− <subscopes anchored="true">
291− <scope name="haskell.keyword.construct.instance.name">
333+ <ends-with>
334+ <template>^(?!\s+\1\S)(?!\s*$)</template>
335+ </ends-with>
336+ <subscopes anchored="true" skip-whitespace="false">
337+ <scope name="haskell.construct.instance.head">
292338 <starts-with>
293339 <expression></expression>
294340 </starts-with>
295341 <ends-with>
296− <expression>(?=(where|^\s*$))</expression>
342+ <expression>where</expression>
343+ <capture number="0" name="haskell.keyword.construct.where" />
297344 </ends-with>
298345 <subscopes>
299− <include syntax="self" collection="type" />
346+ <include syntax="self" collection="type" optional="true" repeat="true" />
300347 </subscopes>
301348 </scope>
302− <scope name="haskell.keyword.construct.where" optional="true">
303− <expression>where</expression>
304− </scope>
349+ <include syntax="self" collection="instance-body" />
305350 </subscopes>
306351 </scope>
307352 </collection>
308353
354+ <collection name="instance-body">
355+ <include syntax="self" collection="definition" />
356+ <include syntax="self" collection="type-definition" />
357+ </collection>
358+
309359 <collection name="type-family-definition">
310360 <scope name="haskell.definition.type-family.type">
361+ <symbol type="type" scope="global">
362+ <context behavior="subtree" foldable="false" />
363+ </symbol>
311364 <starts-with>
312365 <expression>^(\h*)(type\h+family)</expression>
313366 <capture number="2" name="haskell.keyword.construct.type-family" />
@@ -346,7 +399,6 @@
346399 <template>^(?!\s+\1\S)(?!\s*$)</template>
347400 </ends-with>
348401 <subscopes>
349− <include syntax="self" collection="comments" />
350402 <include syntax="self" collection="type" optional="true" repeat="true" />
351403 <scope>
352404 <expression>=</expression>
@@ -358,7 +410,7 @@
358410
359411 <collection name="definition">
360412 <scope name="haskell.definition.type.function">
361− <symbol type="function">
413+ <symbol type="function" scope="local">
362414 <context behavior="whitespace" foldable="true" />
363415 </symbol>
364416 <starts-with>
@@ -370,15 +422,35 @@
370422 <template>^(?!\1\3\s)(?!\s+\1\S)(?!\s*$)</template>
371423 </ends-with>
372424 <subscopes>
373− <include syntax="self" collection="comments" />
374425 <include syntax="self" collection="type-annotation" />
375426 <include syntax="self" collection="implementation" />
376427 </subscopes>
377428 </scope>
378429 </collection>
379430
431+ <collection name="do-bind">
432+ <scope name="do-bind">
433+ <symbol>
434+ <context behavior="whitespace"></context>
435+ </symbol>
436+ <starts-with>
437+ <expression>^(?=((\h*)\S.+<-($|\h)))</expression>
438+ </starts-with>
439+ <ends-with>
440+ <template>^(?!\1)(?!\2\h)(?!\s*$)</template>
441+ </ends-with>
442+ <subscopes>
443+ <include syntax="self" collection="do-pattern" />
444+ <include syntax="self" collection="expressions" />
445+ <!-- <scope name="bind-arrow">
446+ <expression><-</expression>
447+ </scope> -->
448+ </subscopes>
449+ </scope>
450+ </collection>
451+
380452 <collection name="implementation">
381− <scope name="haskell.definition.type.function.implementation">
453+ <scope name="haskell.definition.type.function">
382454 <starts-with>
383455 <expression>^(\h*)(default\h+)?`?(\w(\w|')*)`?($|\h)</expression>
384456 <capture number="2" name="haskell.keyword.construct.default" />
@@ -388,7 +460,6 @@
388460 <template>^(?!\1\3\s)(?!\s+\1\S)(?!\s*$)</template>
389461 </ends-with>
390462 <subscopes>
391− <include syntax="self" collection="comments" />
392463 <include syntax="self" collection="pattern-match" optional="true" repeat="true" />
393464 <scope>
394465 <expression>=</expression>
@@ -401,7 +472,7 @@
401472 </collection>
402473
403474 <collection name="type-annotation">
404− <scope name="haskell.definition.type.function.type-signature">
475+ <scope name="haskell.definition.type.function">
405476 <starts-with>
406477 <expression>^(\h*)`?(\w(\w|')*)`?\h*::($|\h)</expression>
407478 <capture number="2" name="haskell.identifier.function" />
@@ -410,7 +481,6 @@
410481 <template>^(?!\s+\1\S)(?!\s*$)</template>
411482 </ends-with>
412483 <subscopes>
413− <include syntax="self" collection="comments" />
414484 <include syntax="self" collection="type" />
415485 </subscopes>
416486 </scope>
@@ -430,7 +500,6 @@
430500 <template>^(?!\s+\1\S)(?!\s*$)</template>
431501 </ends-with>
432502 <subscopes>
433− <include syntax="self" collection="comments" />
434503 <include syntax="self" collection="type" />
435504 </subscopes>
436505 </scope>
@@ -450,7 +519,6 @@
450519 <template>^(?!\s+\1\S)(?!\s*$)</template>
451520 </ends-with>
452521 <subscopes>
453− <include syntax="self" collection="comments" />
454522 <scope name="haskell.keyword.construct.where">
455523 <expression>where</expression>
456524 </scope>
@@ -466,16 +534,15 @@
466534 <collection name="gadt-constructor">
467535 <scope name="haskell.identifier.type.struct.data.constructor">
468536 <symbol type="constructor">
469− <context behavior="subtree" foldable="true" />
537+ <context behavior="whitespace" />
470538 </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>
539+ <expression>(^|=|\|)\h+([A-Z](\w|')*)</expression>
540+ <capture number="2" name="haskell.identifier.data.name" />
541+ </scope>
542+ <scope name="identifier.type.struct.GADT.constructor">
543+ <symbol type="constructor"></symbol>
544+ <expression>^\h+([A-Z](\w|')*)</expression>
545+ <capture number="1" name="haskell.identifier.data.name" />
479546 </scope>
480547 </collection>
481548
@@ -484,7 +551,6 @@
484551 <expression>deriving(\h+(newtype|stock|anyclass))?</expression>
485552 </scope>
486553 <scope name="haskell.record.construct.deriving.keyword">
487− <include syntax="self" collection="comments" />
488554 <expression>via</expression>
489555 </scope>
490556 </collection>
@@ -503,7 +569,6 @@
503569 <capture number="1" name="haskell.record.bracket" />
504570 </ends-with>
505571 <subscopes>
506− <include syntax="self" collection="comments" />
507572 <include syntax="self" collection="record-definition-field-name" />
508573 <include syntax="self" collection="type" />
509574 </subscopes>
@@ -535,7 +600,6 @@
535600 <expression>\)</expression>
536601 </ends-with>
537602 <subscopes>
538− <include syntax="self" collection="comments" />
539603 <scope name="haskell.construct.type.typle.comma">
540604 <expression>\,</expression>
541605 </scope>
@@ -550,7 +614,6 @@
550614 <expression>\]</expression>
551615 </ends-with>
552616 <subscopes>
553− <include syntax="self" collection="comments" />
554617 <include syntax="self" collection="type" />
555618 </subscopes>
556619 </scope>
@@ -585,7 +648,6 @@
585648 <template>^(?!\s+\1\S)(?!\s*$)</template>
586649 </ends-with>
587650 <subscopes>
588− <include syntax="self" collection="comments" />
589651 <scope name="haskell.keyword.construct.where">
590652 <expression>where</expression>
591653 </scope>
@@ -605,7 +667,6 @@
605667 <capture number="1" name="haskell.type-list.bracket" />
606668 </ends-with>
607669 <subscopes>
608− <include syntax="self" collection="comments" />
609670 <include syntax="self" collection="type" />
610671 </subscopes>
611672 </scope>
@@ -622,7 +683,6 @@
622683 <capture number="1" name="haskell.keyword.construct.lambda" />
623684 </ends-with>
624685 <subscopes>
625− <include syntax="self" collection="comments" />
626686 <include syntax="self" collection="pattern-match" />
627687 </subscopes>
628688 </scope>
@@ -644,7 +704,6 @@
644704 <template>^(?!\1\s*\S)(?!s*$)</template>
645705 </ends-with>
646706 <subscopes>
647− <include syntax="self" collection="comments" />
648707 <include syntax="self" collection="definition" />
649708 </subscopes>
650709 </scope>
@@ -684,12 +743,12 @@
684743
685744
686745 <collection name="strings">
687− <scope name="haskell.string.double-quoted" spell-check="true">
746+ <scope name="haskell.string.double-quoted">
688747 <starts-with>
689− <expression>"</expression>
748+ <expression>"</expression>
690749 </starts-with>
691750 <ends-with>
692− <expression>"</expression>
751+ <expression>"</expression>
693752 </ends-with>
694753 <subscopes>
695754 <scope name="haskell.string.escape-sequences">
@@ -726,7 +785,6 @@
726785 </ends-with>
727786 <subscopes>
728787 <scope name="identifier.haskell.type">
729− <symbol type="expression" />
730788 <symbol type="expression" />
731789 <expression>([A-Z](\w|')*)\h*(\(\h*\.\.\h*\))?</expression>
732790 <capture number="1" name="identifier.type" />
@@ -751,7 +809,6 @@
751809 </ends-with>
752810 <subscopes>
753811 <scope name="haskell.construct.qualified">
754− <symbol type="expression" />
755812 <expression>qualified</expression>
756813 <capture number="0" name="haskell.construct.keyword.qualified" />
757814 </scope>
@@ -769,7 +826,6 @@
769826 </ends-with>
770827 <subscopes anchored="true">
771828 <include syntax="self" collection="import-list" />
772− <symbol type="expression" />
773829 </subscopes>
774830 </scope>
775831
@@ -803,7 +859,6 @@
803859 </ends-with>
804860 <subscopes>
805861 <scope name="haskell.identifier.struct">
806− <symbol type="expression" />
807862 <symbol type="reference" scope="local" />
808863 <expression>([A-Z](\w|')*)\h*(\(\h*\.\.\h*\))?</expression>
809864 <capture number="1" name="haskell.import-list.identifier.type.name" />
@@ -817,6 +872,13 @@
817872 </scope>
818873 </collection>
819874
875+ <!-- <collection name="special">
876+ <scope>
877+ <expression>(;|,)</expression>
878+ </scope>
879+ </collection> -->
880+
881+
820882 <collection name="reservedop">
821883 <scope name="keyword.operator">
822884 <expression>(\.\.|:|::|=|\\|\||<-|->|@|~|=>)</expression>
@@ -824,11 +886,10 @@
824886 </collection>
825887
826888 <collection name="keywords">
827− <scope name="haskell.keyword.self">
889+ <scope name="haskell.keyword.modifier">
828890 <symbol type="keyword" />
829891 <strings>
830892 <string>do</string>
831− <string>mdo</string>
832893 <string>in</string>
833894 <string>infix</string>
834895 <string>infixl</string>
@@ -866,18 +927,20 @@
866927 <strings>
867928 <string>undefined</string>
868929 <string>_</string>
869− <string>@</string>
870930 </strings>
871931 </scope>
872932 </collection>
873933
874934 <collection name="comments">
875935 <scope name="haskell.comment.single" spell-check="true">
876− <symbol type="comment" />
877− <expression> --.*$</expression>
936+ <starts-with>
937+ <expression>--</expression>
938+ </starts-with>
939+ <ends-with>
940+ <expression>$</expression>
941+ </ends-with>
878942 </scope>
879943 <scope name="haskell.comment.block" spell-check="true">
880− <symbol type="comment" />
881944 <starts-with>
882945 <expression>{-</expression>
883946 </starts-with>