Skip to content

Commit

Permalink
Merge pull request #205 from unisonweb/master
Browse files Browse the repository at this point in the history
merge master into wip/typechecker
  • Loading branch information
pchiusano committed Jun 25, 2018
2 parents 7b634ba + a698e19 commit c75eb1f
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 2 deletions.
112 changes: 112 additions & 0 deletions editor-support/atom/language-unison/grammars/unison.cson
@@ -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: '--.*$'
16 changes: 16 additions & 0 deletions editor-support/atom/language-unison/package.json
@@ -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"
}
}
3 changes: 3 additions & 0 deletions editor-support/atom/language-unison/settings/settings.cson
@@ -0,0 +1,3 @@
'.source.unison':
'editor':
commentStart: '--'
3 changes: 1 addition & 2 deletions stack.yaml
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions unison-src/corpus.u
@@ -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

0 comments on commit c75eb1f

Please sign in to comment.