Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions grammars/purescript.cson
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,32 @@
]
'derive_declaration':
'patterns': [
{
'name': 'meta.declaration.derive.attached.purescript'
'begin': '^\\s*\\b(derive)(\\s+newtype)?\\s*(\\()'
'end': '(\\))(?:\\s+(via)\\b)?'
'beginCaptures':
'1':
'name': 'keyword.other.purescript'
'2':
'name': 'keyword.other.purescript'
'3':
'name': 'punctuation.paren.begin.purescript'
'endCaptures':
'1':
'name': 'punctuation.paren.end.purescript'
'2':
'name': 'keyword.other.purescript'
'patterns': [
{
'include': '#type_signature'
}
{
'name': 'punctuation.separator.comma.purescript'
'match': ','
}
]
}
{
'name': 'meta.declaration.derive.purescript'
'begin': '^\\s*\\b(derive)(\\s+newtype)?(\\s+instance)?(?!\')\\b'
Expand Down
17 changes: 17 additions & 0 deletions src/purescript.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,23 @@ purescriptGrammar =

derive_declaration:
patterns: [
name: 'meta.declaration.derive.attached'
begin: /^\s*\b(derive)(\s+newtype)?\s*(\()/
end: /(\))(?:\s+(via)\b)?/
beginCaptures:
1: name: 'keyword.other'
2: name: 'keyword.other'
3: name: 'punctuation.paren.begin'
endCaptures:
1: name: 'punctuation.paren.end'
2: name: 'keyword.other'
patterns: [
include: '#type_signature'
,
name: 'punctuation.separator.comma'
match: /,/
]
,
name: 'meta.declaration.derive'
begin: /^\s*\b(derive)(\s+newtype)?(\s+instance)?(?!')\b/
end: /^(?=\S)/
Expand Down
18 changes: 18 additions & 0 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,24 @@ derive instance genericCmd
:: Generic PhonerCmd _


-- attached derive clauses
newtype TodoId = TodoId UUID
derive (Newtype)
derive newtype (Eq, Ord, Show)
derive (ReadForeign, WriteForeign) via Int

data Color = Red | Green | Blue
derive (Eq, Ord, Show)

newtype Score = Score Int
derive newtype (Semiring, Ring)

newtype Wrapper = Wrapper String
derive (Generic)
derive (Encode, Decode) via String
derive newtype (Eq)


-- TODO: multi-line, double-colons
derive instance genericCmd ::
Generic PhonerCmd _
Expand Down