-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
touch up, operator version, method calls work
- Loading branch information
Showing
6 changed files
with
182 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,39 @@ jobs: | |
|
||
- name: run tests | ||
run: nimble tests | ||
|
||
docs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: jiro4989/setup-nim-action@v1 | ||
|
||
- name: install nimbleutils | ||
run: nimble install -y https://github.com/metagn/nimbleutils@#HEAD | ||
|
||
- name: install dependencies | ||
run: nimble install -y | ||
|
||
- name: compile docs | ||
run: nimble docs | ||
|
||
- name: move to subfolder | ||
run: | | ||
mkdir pages | ||
mv docs pages/ | ||
cd pages | ||
git init | ||
git add -A | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git commit -m 'deploy' | ||
- name: push to branch | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: gh-pages | ||
force: true | ||
directory: ./pages/ | ||
if: github.event_name != 'pull_request' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import spread | ||
|
||
block: | ||
proc foo(a, b, c: int): string = $(a, b, c) | ||
|
||
block: | ||
# regular call: | ||
let x = foo.spread: | ||
a = 1 | ||
c = 3 | ||
b = 2 | ||
doAssert x == "(1, 2, 3)" | ||
|
||
# method call syntax: | ||
let y = spread 1.foo: | ||
c = 3 | ||
b = 2 | ||
let z = spread 1.foo(2): | ||
c = 3 | ||
doAssert x == y and y == z | ||
|
||
block: | ||
# operator version: | ||
let a = ...foo: | ||
1 | ||
c = 3 | ||
b = 2 | ||
doAssert a == "(1, 2, 3)" | ||
|
||
# operator allows inline version with `do`: | ||
let b = 1 + (...min do: | ||
2 | ||
3) | ||
doAssert b == 3 | ||
|
||
block: | ||
# array constructor: | ||
const arr = [].spread: | ||
1 | ||
2 | ||
3 | ||
doAssert arr == [1, 2, 3] | ||
|
||
# table constructor | ||
let tab = spread {:}: | ||
"a" = 1 # constructors convert = in a statement to : | ||
_("b": 2, "c": 3) # all arguments of _ are spread directly | ||
doAssert tab == {"a": 1, "b": 2, "c": 3} | ||
|
||
block: | ||
# object or tuple constructors | ||
type Foo = object | ||
a, b, c: int | ||
let obj = spread Foo(_: _): | ||
a = 1 | ||
c = 3 | ||
b = 2 | ||
doAssert obj == Foo(a: 1, b: 2, c: 3) | ||
|