Skip to content

Commit e617fb5

Browse files
committed
Add support for modifiers/linearity annotations
1 parent dbcfc84 commit e617fb5

File tree

4 files changed

+70
-3
lines changed

4 files changed

+70
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- Ensure highlighting of unicode forall syntax matches that of alphabetic forall syntax
1010
([#175](https://github.com/JustusAdam/language-haskell/issues/175)).
1111
- Fix highlighting of empty quasi-quotations such as `[i||]`.
12+
- Support GHC 9.0 pragmas: `LinearTypes`, `QualifiedDo`, `LexicalNegation`.
13+
- Add support for [modifiers](https://github.com/ghc-proposals/ghc-proposals/pull/370), e.g. `id :: a %1 -> a`.
1214

1315
## 3.3.0 - 25.06.2020
1416

syntaxes/haskell.YAML-tmLanguage

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,14 +1456,15 @@ repository:
14561456
- match: >-
14571457
(?x)
14581458
(?<![\p{Ll}_\p{Lu}\p{Lt}\p{Nd}\p{S}\p{P}&&[^(,;\[`{]]) # Disallow closing characters
1459-
(?:(~)|(!)|(-)|(\$)|(\$\$))
1459+
(?:(~)|(!)|(-)|(\$\$)|(\$)|(%))
14601460
(?=[\p{Ll}_'\p{Lu}\p{Lt}\p{Nd}\(\{\[]) # Require opening character (non operator symbol)
14611461
captures:
14621462
'1': {name: keyword.operator.prefix.tilde.haskell}
14631463
'2': {name: keyword.operator.prefix.bang.haskell}
14641464
'3': {name: keyword.operator.prefix.minus.haskell}
1465-
'4': {name: keyword.operator.prefix.dollar.haskell}
1466-
'5': {name: keyword.operator.prefix.double-dollar.haskell}
1465+
'4': {name: keyword.operator.prefix.double-dollar.haskell}
1466+
'5': {name: keyword.operator.prefix.dollar.haskell}
1467+
'6': {name: keyword.operator.prefix.modifier.haskell}
14671468
type_operator:
14681469
patterns:
14691470
# Symbolic type operator (optional promotion & qualification)

test/tests/LinearTypes.hs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-- SYNTAX TEST "source.haskell" "LinearTypes"
2+
3+
{-# LANGUAGE LinearTypes #-}
4+
-- ^^^^^^^^^^^ keyword.other.preprocessor.extension.haskell
5+
6+
construct :: a %1 -> T1 a
7+
-- ^ keyword.operator.prefix.modifier.haskell
8+
construct x = MkT1 x
9+
10+
deconstruct :: T1 a %1 -> a
11+
-- ^ keyword.operator.prefix.modifier.haskell
12+
deconstruct (MkT1 x) = x
13+
14+
data T2 a b c where
15+
MkT2 :: a -> b %1 -> c %1 -> T2 a b c
16+
-- ^ ^ keyword.operator.prefix.modifier.haskell
17+
18+
data T3 a m where
19+
MkT3 :: a %m -> T3 a m
20+
-- ^ keyword.operator.prefix.modifier.haskell
21+
22+
23+
f2 :: Int %Many -> Bool
24+
-- ^ keyword.operator.prefix.modifier.haskell
25+
f3 :: Int %m -> Bool
26+
-- ^ keyword.operator.prefix.modifier.haskell
27+
f4 :: Int %(m :: Multiplicity) -> Bool
28+
-- ^ keyword.operator.prefix.modifier.haskell
29+
30+
map :: forall (m :: Multiplicity). (a %m -> b) -> [a] %m -> [b]
31+
-- ^ ^ keyword.operator.prefix.modifier.haskell
32+
33+
foo :: a % b -> c % d
34+
-- ^ ^ - keyword.operator.prefix.modifier.haskell
35+
36+
bar :: a %%b -> c %-% d
37+
-- ^^ ^ ^ - keyword.operator.prefix.modifier.haskell
38+

test/tests/QualifiedDo.hs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
-- SYNTAX TEST "source.haskell" "QualifiedDo"
2+
3+
{-# LANGUAGE QualifiedDo #-}
4+
-- ^^^^^^^^^^^ keyword.other.preprocessor.extension.haskell
5+
6+
f :: IO ()
7+
f = do
8+
-- ^^ keyword.control.do.haskell
9+
x <- runMAC $
10+
11+
MAC.mdo
12+
-- ^^^^ entity.name.namespace.haskell
13+
-- ^^^ keyword.control.mdo.haskell
14+
d <- label "y"
15+
box $
16+
17+
L.do
18+
-- ^^ entity.name.namespace.haskell
19+
-- ^^ keyword.control.do.haskell
20+
r <- L.f d
21+
L.g r
22+
L.return r
23+
24+
MAC.return d
25+
26+
print x

0 commit comments

Comments
 (0)