diff --git a/bun.lock b/bun.lock new file mode 100644 index 0000000..f838433 --- /dev/null +++ b/bun.lock @@ -0,0 +1,89 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "language-purescript", + "devDependencies": { + "coffee-script": "~1.9.0", + "season": "~2.0.0", + }, + }, + }, + "packages": { + "StringScanner": ["StringScanner@0.0.3", "", {}, "sha1-vwbs/ckARnEfTmF1VJJDt4zrOKo="], + + "abbrev": ["abbrev@1.1.1", "", {}, "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="], + + "amdefine": ["amdefine@1.0.1", "", {}, "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU="], + + "async": ["async@1.5.2", "", {}, "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="], + + "balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="], + + "brace-expansion": ["brace-expansion@1.1.11", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA=="], + + "coffee-script": ["coffee-script@1.9.3", "", { "bin": { "cake": "bin/cake", "coffee": "bin/coffee" } }, "sha1-WW5ug/z8tnxZZKtw1ES+/wrASsc="], + + "coffee-script-redux": ["coffee-script-redux@2.0.0-beta8", "", { "dependencies": { "StringScanner": "~0.0.3", "nopt": "~2.1.2" }, "optionalDependencies": { "cscodegen": "git://github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", "escodegen": "~0.0.24", "esmangle": "~0.0.8", "source-map": "0.1.11" }, "bin": { "coffee": "bin/coffee" } }, "sha1-D9e4QXNA3Q0zno9v2LS4cWlW6NU="], + + "concat-map": ["concat-map@0.0.1", "", {}, "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="], + + "cscodegen": ["cscodegen@git+ssh://git@github.com/michaelficarra/cscodegen.git#73fd7202ac086c26f18c9d56f025b18b3c6f5383", { "bin": { "cake": "bin/cscodegen" } }, "73fd7202ac086c26f18c9d56f025b18b3c6f5383"], + + "cson-safe": ["cson-safe@0.1.1", "", { "dependencies": { "coffee-script-redux": "2.0.0-beta8" } }, "sha1-XFa4BC2UhCqTIg+mWn81f83gwnM="], + + "escodegen": ["escodegen@0.0.28", "", { "dependencies": { "esprima": "~1.0.2", "estraverse": "~1.3.0" }, "optionalDependencies": { "source-map": ">= 0.1.2" }, "bin": { "escodegen": "bin/escodegen.js", "esgenerate": "bin/esgenerate.js" } }, "sha1-Dk/xcV8yh3XWyrUaxEpAbNer/9M="], + + "escope": ["escope@1.0.3", "", { "dependencies": { "estraverse": "^2.0.0" } }, "sha1-dZ3OhJbEJI/sLQyq9BCLzz8af10="], + + "esmangle": ["esmangle@0.0.17", "", { "dependencies": { "escodegen": "~ 0.0.28", "escope": "~ 1.0.0", "esprima": "~ 1.0.2", "esshorten": "~ 0.0.2", "estraverse": "~ 1.3.2", "optimist": "*", "source-map": "~ 0.1.8" }, "bin": "bin/esmangle.js" }, "sha1-TFyTYHzeXRJ2utOW6DYinbpo2Qw="], + + "esprima": ["esprima@1.0.4", "", { "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" } }, "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0="], + + "esshorten": ["esshorten@0.0.2", "", { "dependencies": { "escope": "~ 1.0.0", "estraverse": "~ 1.2.0" } }, "sha1-KKZS8e/UDI4if4xt59vmtWDugSk="], + + "estraverse": ["estraverse@1.3.2", "", {}, "sha1-N8K4k+8T1yPydth41g2FNRUqbEI="], + + "fs-plus": ["fs-plus@2.10.1", "", { "dependencies": { "async": "^1.5.2", "mkdirp": "^0.5.1", "rimraf": "^2.5.2", "underscore-plus": "1.x" } }, "sha1-MgR4HXhAYR5jZOe2+wWMljJ8WqU="], + + "fs.realpath": ["fs.realpath@1.0.0", "", {}, "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="], + + "glob": ["glob@7.1.6", "", { "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA=="], + + "inflight": ["inflight@1.0.6", "", { "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk="], + + "inherits": ["inherits@2.0.4", "", {}, "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="], + + "minimatch": ["minimatch@3.0.4", "", { "dependencies": { "brace-expansion": "^1.1.7" } }, "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA=="], + + "minimist": ["minimist@1.2.5", "", {}, "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="], + + "mkdirp": ["mkdirp@0.5.5", "", { "dependencies": { "minimist": "^1.2.5" }, "bin": "bin/cmd.js" }, "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ=="], + + "nopt": ["nopt@2.1.2", "", { "dependencies": { "abbrev": "1" }, "bin": "bin/nopt.js" }, "sha1-bMzZd7gBMqB3MdbozljCyDA8+a8="], + + "once": ["once@1.4.0", "", { "dependencies": { "wrappy": "1" } }, "sha1-WDsap3WWHUsROsF9nFC6753Xa9E="], + + "optimist": ["optimist@0.4.0", "", { "dependencies": { "wordwrap": "~0.0.2" } }, "sha1-y47Dfy/jqphky2eidSUOfhliCiU="], + + "path-is-absolute": ["path-is-absolute@1.0.1", "", {}, "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="], + + "rimraf": ["rimraf@2.7.1", "", { "dependencies": { "glob": "^7.1.3" }, "bin": "bin.js" }, "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w=="], + + "season": ["season@2.0.0", "", { "dependencies": { "cson-safe": "~0.1.1", "fs-plus": "2.x", "optimist": "~0.4.0", "underscore-plus": "1.x" }, "bin": { "csonc": "bin/csonc" } }, "sha1-EKjXvO4an/ji/qcCji7cfJGNK30="], + + "source-map": ["source-map@0.1.11", "", { "dependencies": { "amdefine": ">=0.0.4" } }, "sha1-Lu8v1lp0wXmICuXuaXXZnOIet7Q="], + + "underscore": ["underscore@1.13.1", "", {}, "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g=="], + + "underscore-plus": ["underscore-plus@1.7.0", "", { "dependencies": { "underscore": "^1.9.1" } }, "sha512-A3BEzkeicFLnr+U/Q3EyWwJAQPbA19mtZZ4h+lLq3ttm9kn8WC4R3YpuJZEXmWdLjYP47Zc8aLZm9kwdv+zzvA=="], + + "wordwrap": ["wordwrap@0.0.3", "", {}, "sha1-o9XabNXAvAAI03I0u68b7WMFkQc="], + + "wrappy": ["wrappy@1.0.2", "", {}, "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="], + + "escope/estraverse": ["estraverse@2.0.0", "", {}, "sha1-WuRpYyQ2ACBmdMyySgnhZnT83KE="], + + "esshorten/estraverse": ["estraverse@1.2.0", "", {}, "sha1-aj3IpGpdZ2blZoY5/Hgpds5WYP0="], + } +} diff --git a/grammars/purescript.cson b/grammars/purescript.cson index 0834122..f028f6e 100644 --- a/grammars/purescript.cson +++ b/grammars/purescript.cson @@ -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' diff --git a/src/purescript.coffee b/src/purescript.coffee index d547336..5b3686c 100644 --- a/src/purescript.coffee +++ b/src/purescript.coffee @@ -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)/ diff --git a/test/Main.purs b/test/Main.purs index 66108d9..c203396 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -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 _