From d1afde3c2fcff20ab1fbcaee82a8f11a03267efa Mon Sep 17 00:00:00 2001 From: Justus Adam Date: Tue, 21 Apr 2020 11:44:35 +0100 Subject: [PATCH] Added support for multiline type aliases Closes #111 --- syntaxes/haskell.tmLanguage | 33 +++++++++++++++++++++------------ test/syntax-examples/test.hs | 14 ++++++++++++++ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/syntaxes/haskell.tmLanguage b/syntaxes/haskell.tmLanguage index 444c395..46c4787 100644 --- a/syntaxes/haskell.tmLanguage +++ b/syntaxes/haskell.tmLanguage @@ -146,7 +146,7 @@ match (?x) - \b(data|newtype) + ^(\s)*\b(data|newtype) \s+ ([\p{Lu}\p{Lt}][\w\p{Nd}_']*) ((?:\s+[\p{Ll}][\w\p{Nd}_']*)*?) @@ -155,17 +155,17 @@ captures - 1 + 2 name keyword.other.haskell - 2 + 3 name storage.type.haskell - 3 + 4 patterns @@ -177,7 +177,7 @@ - 4 + 5 name keyword.other.haskell @@ -185,9 +185,9 @@ - match + begin (?x) - \b(type) + ^(\s*)\b(type) \s+ ([^=]*) (?: @@ -196,14 +196,14 @@ (.*) )?\s*$ - captures + beginCaptures - 1 + 2 name keyword.other.haskell - 2 + 3 patterns @@ -213,12 +213,12 @@ - 3 + 4 name keyword.other.haskell - 4 + 5 patterns @@ -229,6 +229,15 @@ + patterns + + + include + #type_signature + + + end + (?=(<\-)|(^(\1)?[^\s]|})) begin diff --git a/test/syntax-examples/test.hs b/test/syntax-examples/test.hs index ff58dde..65f1797 100644 --- a/test/syntax-examples/test.hs +++ b/test/syntax-examples/test.hs @@ -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