Skip to content

Commit

Permalink
Added support for multiline type aliases
Browse files Browse the repository at this point in the history
Closes #111
  • Loading branch information
JustusAdam committed Apr 21, 2020
1 parent 797fd42 commit d1afde3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
33 changes: 21 additions & 12 deletions syntaxes/haskell.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<dict>
<key>match</key>
<string>(?x)
\b(data|newtype)
^(\s)*\b(data|newtype)
\s+
([\p{Lu}\p{Lt}][\w\p{Nd}_']*)
((?:\s+[\p{Ll}][\w\p{Nd}_']*)*?)
Expand All @@ -155,17 +155,17 @@
</string>
<key>captures</key>
<dict>
<key>1</key>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.other.haskell</string>
</dict>
<key>2</key>
<key>3</key>
<dict>
<key>name</key>
<string>storage.type.haskell</string>
</dict>
<key>3</key>
<key>4</key>
<dict>
<key>patterns</key>
<array>
Expand All @@ -177,17 +177,17 @@
</dict>
</array>
</dict>
<key>4</key>
<key>5</key>
<dict>
<key>name</key>
<string>keyword.other.haskell</string>
</dict>
</dict>
</dict>
<dict>
<key>match</key>
<key>begin</key>
<string>(?x)
\b(type)
^(\s*)\b(type)
\s+
([^=]*)
(?:
Expand All @@ -196,14 +196,14 @@
(.*)
)?\s*$
</string>
<key>captures</key>
<key>beginCaptures</key>
<dict>
<key>1</key>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.other.haskell</string>
</dict>
<key>2</key>
<key>3</key>
<dict>
<key>patterns</key>
<array>
Expand All @@ -213,12 +213,12 @@
</dict>
</array>
</dict>
<key>3</key>
<key>4</key>
<dict>
<key>name</key>
<string>keyword.other.haskell</string>
</dict>
<key>4</key>
<key>5</key>
<dict>
<key>patterns</key>
<array>
Expand All @@ -229,6 +229,15 @@
</array>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#type_signature</string>
</dict>
</array>
<key>end</key>
<string>(?=(&lt;\-)|(^(\1)?[^\s]|}))</string>
</dict>
<dict>
<key>begin</key>
Expand Down
14 changes: 14 additions & 0 deletions test/syntax-examples/test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ data T3 = T3

type MyType = MyData String

-- Multi-line type aliases

type T a =
Constr
a
Int

-- Multi line type alias with infix constructors

type UserApi = "users" :> Body '[JSON]
:> Post '[JSON]
:<|> "users" :> Capture "userid"
:> ReqBody '[JSON]

class Empty

abind :: Type
Expand Down

0 comments on commit d1afde3

Please sign in to comment.