Merge pull request #205 from unisonweb/master

merge master into wip/typechecker
This commit is contained in:
Paul Chiusano 2018-06-25 18:39:29 -05:00 committed by GitHub
commit c75eb1f4e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 161 additions and 2 deletions

View File

@ -0,0 +1,112 @@
scopeName: 'source.unison'
name: 'Unison'
fileTypes: ['u']
limitLineLength: false
patterns: [
{ include: '#comment' }
{ include: '#boolean' }
{ include: '#numeric' }
{ include: '#text'}
{ include: '#case_of' }
{ include: '#if' }
{ include: '#annotation'}
{ include: '#type_operators' }
{ include: '#unsorted_reserved_chars' }
{ include: '#unsorted_keywords' }
]
repository:
unsorted_reserved_chars:
match: '(,)|(`)|(\\[)|(\\])|({)|(})|(@)|(\\|)'
captures:
1: {name: 'punctuation.separator.delimiter.unison'}
2: {name: 'punctuation.definition.entity.unison'}
3: {name: 'punctuation.definition.list.begin.unison'}
4: {name: 'punctuation.definition.list.end.unison'}
5: {name: 'punctuation.definition.effect.begin.unison'}
6: {name: 'punctuation.definition.effect.end.unison'}
7: {name: 'punctuation.operator.assignment.as.unison'}
8: {name: 'punctuation.separator.pipe.unison'}
if:
match: '(\\s|^)(if|then|else|and|or)(?=\\s|^)'
captures: {2: {name: 'keyword.control.unison'}}
annotation:
name: 'meta.function.type-declaration.unison'
match: '(\\S+)\\s+(:)(?=\\s)'
captures:
1: {name: 'entity.name.function.unison' }
2: {name: 'keyword.other.colon.unison' }
type_operators:
match: '\\s(forall|∀)|(->)(?=\\s)'
captures:
1: {name: 'keyword.other.forall.unison'}
2: {name: 'keyword.other.arrow.unison'}
case_of:
match: '(\\s|^)(case|of|->)(?=\\s|$)'
captures:
2: {name: 'keyword.control.case.unison'}
unsorted_keywords:
match: '(\\s|^)(let|alias|handle|in|namespace|type|effect)(?=\\s|$)'
captures:
2: {name: 'keyword.control.unison'}
boolean:
patterns: [
{include: '#true'}
{include: '#false'}
]
numeric:
patterns: [
{include: '#float'}
{include: '#int64'}
{include: '#uint64'}
]
text:
name: 'string.quoted.double.unison'
match: '(")(.*?)(")'
captures:
1: {name: 'punctuation.definition.string.begin.unison'}
3: {name: 'punctuation.definition.string.end.unison'}
true:
match: 'true'
name: 'constant.language.boolean.true.unison'
false:
match: 'false'
name: 'constant.language.boolean.false.unison'
int64:
match: '([^\\w\\d]|^)([+-]\\d+)'
captures:
2: {name: 'constant.numeric.integer.signed.unison'}
uint64:
match: '([^+\\-\\w\\d]|^)(\\d+)'
captures:
2: {name: 'constant.numeric.integer.unsigned.unison'}
float:
match: '([^+\\-\\w\\d]|^)([+-]?\\d+\\.\\d*)'
captures:
2: {name: 'constant.numeric.decimal.unison'}
comment:
patterns: [
{include: "#block_comment"}
{include: "#line_comment"}
]
block_comment:
name: 'comment.block.unison'
begin: '{-'
end: '-}'
beginCaptures:
0:
name: 'punctuation.definition.comment.begin.unison'
endCaptures:
0:
name: 'punctuation.definition.comment.end.unison'
patterns: [{ include: '#block_comment' }]
line_comment:
name: 'comment.line.double-dash.unison'
match: '--.*$'

View File

@ -0,0 +1,16 @@
{
"name": "language-unison",
"version": "0.0.0",
"description": "An example language grammar package",
"repository": "https://github.com/user/package-name",
"keywords": [
"syntax",
"highlighting",
"grammar"
],
"license": "MIT",
"bugs": "https://github.com/user/package-name/issues",
"engines": {
"atom": ">=1.0.0 <2.0.0"
}
}

View File

@ -0,0 +1,3 @@
'.source.unison':
'editor':
commentStart: '--'

View File

@ -8,8 +8,7 @@ packages:
- parser-typechecker
#compiler-check: match-exact
resolver: lts-11.9
compiler: ghc-8.4.2
resolver: nightly-2018-06-25
extra-deps:
- base58-bytestring-0.1.0

29
unison-src/corpus.u Normal file
View File

@ -0,0 +1,29 @@
-- a comment
{- {-
a multi-line nested comment
-} still a comment
-}
type Optional a = None | Some a
Optional.isEmpty : ∀ a . Optional a -> Boolean
Optional.isEmpty o = case o of
Optional.None -> true
Optional.Some hi@_ -> false
(|>) : forall a b . a -> (a -> b) -> b
a |> f = f a
let
foo : UInt64 -> UInt64
foo x = case if x >_UInt64 1 then x +_UInt64 1 else 0
x = [1.,2.5]
"let case if"
|> Text.size
|> Stream.from-int64
|> Stream.take 10
|> Stream.fold-left -0 (+_Int64)
|> Stream.fold-left-0 (+_Int64)
|> Optional.Some
+1.0