Skip to content

Commit

Permalink
More work on end codition for type signatures
Browse files Browse the repository at this point in the history
Closes #89
  • Loading branch information
JustusAdam committed Apr 22, 2020
1 parent 57ed16d commit a8181ec
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
([#104](https://github.com/JustusAdam/language-haskell/issues/104))
- Pragmas are now case insensitive ([#81](https://github.com/JustusAdam/language-haskell/issues/81))
- Fixed matcher for end of type annotations. Facilitates indented `module` blocks
([#91](https://github.com/JustusAdam/language-haskell/issues/91))
([#91](https://github.com/JustusAdam/language-haskell/issues/91)) and standalone deriving
([#89](https://github.com/JustusAdam/language-haskell/issues/89))
- Updated cabal grammar ([#93](https://github.com/JustusAdam/language-haskell/issues/93))
- As a substantial internal change the grammar migratd to the YAML format, to make it easier to
maintain and develop with.
Expand Down
24 changes: 17 additions & 7 deletions syntaxes/haskell.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ patterns:
- {include: '#type_signature'}
patterns:
- {include: '#type_signature'}
end: '(?=(<\-)|(^(\1)?[^\s]|}))'
- begin: '\b(instance)(\b(?!''))'
end: |
(?x)
(?=(<\-)|})
| ^(?!\1\s+\S|\s*$) # at least one, no-further indented, non-whitespace character. I.e. a same-level declaration/implementation
- begin: '^(\s*)\b(instance)(\b(?!''))'
beginCaptures:
'1': {name: keyword.other.haskell}
end: '(\b(where)(\b(?!''))|(?=^\S))'
'2': {name: keyword.other.haskell}
end: |
(?x)
\b(where)\b(?!')
| ^(?!\1\s+\S|\s*$) # at least one, no-further indented, non-whitespace character. I.e. a same-level declaration/implementation
endCaptures:
'1': {name: keyword.other.haskell}
name: meta.declaration.instance.haskell
Expand All @@ -110,6 +116,11 @@ patterns:
name: meta.deriving.haskell
patterns:
- {include: '#derivings'}
- match: '\b(deriving) (instance)\b(.*)$'
captures:
'1': {name: keyword.other.haskell}
'2': {name: keyword.other.haskell}
'3': {patterns: [{include: '#type_signature'}]}
- match: >-
(deriving)\s+([\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*)
captures:
Expand All @@ -118,8 +129,7 @@ patterns:
name: meta.deriving.haskell
- match: >-
(?x)\b
( deriving
| where
( where
| type([\\t ]+(family|role))
| let
| in
Expand Down Expand Up @@ -191,7 +201,7 @@ patterns:
(<\-) # we are the left side of a `x :: Type <- expr` bind statement
| } # A block closed? Maybe this should also include `;`, because non-indentation based `do`
)
| ^(?!\1[^\s]) # at least one, no-further indented, non-whitespace character. I.e. a same-level declaration/implementation
| ^(?!\1\s+\S|\s*$) # at least one, no-further indented, non-whitespace character. I.e. a same-level declaration/implementation
- {include: '#data_constructor'}
- {include: '#qualifier'}
- {include: '#comments'}
Expand Down
6 changes: 5 additions & 1 deletion test/syntax-examples/test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ module M
myFoo :: Foo
myFoo = foo


deriving instance SomeClass => Eq a
deriving instance Ord a => Ord (Expr a)

class Foo x where
myFoo :: Foo

Expand Down Expand Up @@ -73,7 +77,7 @@ type T a =
Constr
a
Int
>

-- Multi line type alias with infix constructors

type UserApi = "users" :> Body '[JSON]
Expand Down

0 comments on commit a8181ec

Please sign in to comment.