-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples should be formatted and typechecked
- Loading branch information
1 parent
307cd8b
commit 62b237a
Showing
18 changed files
with
538 additions
and
516 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 |
---|---|---|
|
@@ -21,40 +21,15 @@ concurrency: | |
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}" | ||
cancel-in-progress: true | ||
env: | ||
SKIP: ormolu | ||
SKIP: ormolu format-juvix-examples | ||
|
||
jobs: | ||
<<<<<<< HEAD | ||
|
||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
- uses: pre-commit/[email protected] | ||
|
||
clang-format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: jidicula/[email protected] | ||
with: | ||
clang-format-version: '15' | ||
check-path: runtime/src | ||
|
||
ormolu: | ||
======= | ||
pre-commit: | ||
>>>>>>> 9606ba98 (w.i.p) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: mrkkrp/ormolu-action@v11 | ||
with: | ||
<<<<<<< HEAD | ||
======= | ||
python-version: "3.11" | ||
- uses: pre-commit/[email protected] | ||
|
||
|
@@ -64,7 +39,6 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- uses: mrkkrp/ormolu-action@v11 | ||
with: | ||
>>>>>>> 9606ba98 (w.i.p) | ||
version: 0.5.2.0 | ||
extra-args: >- | ||
--ghc-opt -XDerivingStrategies --ghc-opt -XImportQualifiedPost | ||
|
@@ -136,6 +110,12 @@ jobs: | |
cd main | ||
make test | ||
- name: Typecheck and format Juvix examples | ||
if: ${{ success() }} | ||
run: | | ||
cd main | ||
make -s juvix-format | ||
- name: Add ~/.local/bin to PATH | ||
run: | | ||
echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
|
@@ -243,11 +223,7 @@ jobs: | |
- name: Deploy HTML to github pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
<<<<<<< HEAD | ||
github_token: '${{ secrets.GITHUB_TOKEN }}' | ||
======= | ||
github_token: "${{ secrets.GITHUB_TOKEN }}" | ||
>>>>>>> 9606ba98 (w.i.p) | ||
publish_dir: main/book/html | ||
enable_jekyll: false | ||
cname: docs.juvix.org | ||
|
@@ -270,10 +246,6 @@ jobs: | |
run: | | ||
brew install icu4c | ||
brew link icu4c --force | ||
<<<<<<< HEAD | ||
|
||
======= | ||
>>>>>>> 9606ba98 (w.i.p) | ||
- name: Download and extract wasi-sysroot | ||
run: > | ||
|
@@ -322,6 +294,12 @@ jobs: | |
make CC=$CC LIBTOOL=$LIBTOOL test | ||
make CC=$CC LIBTOOL=$LIBTOOL install | ||
- name: Typecheck and format Juvix examples | ||
if: ${{ success() }} | ||
run: | | ||
cd main | ||
make -s juvix-format | ||
- name: Add ~/.local/bin to PATH | ||
run: | | ||
echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
module Demo; | ||
-- standard library prelude | ||
open import Stdlib.Prelude; | ||
-- for comparisons on natural numbers | ||
open import Stdlib.Data.Nat.Ord; | ||
-- for Ordering | ||
open import Stdlib.Data.Ord; | ||
|
||
even : Nat → Bool; | ||
even zero := true; | ||
even (suc zero) := false; | ||
even (suc (suc n)) := even n; | ||
|
||
even' : Nat → Bool; | ||
even' n := mod n 2 == 0; | ||
|
||
-- base 2 logarithm rounded down | ||
terminating | ||
log2 : Nat → Nat; | ||
log2 n := if (n <= 1) 0 (suc (log2 (div n 2))); | ||
|
||
type Tree (A : Type) := | ||
| leaf : A → Tree A | ||
| node : A → Tree A → Tree A → Tree A; | ||
|
||
mirror : {A : Type} → Tree A → Tree A; | ||
mirror t@(leaf _) := t; | ||
mirror (node x l r) := node x (mirror r) (mirror l); | ||
|
||
tree : Tree Nat; | ||
tree := node 2 (node 3 (leaf 0) (leaf 1)) (leaf 7); | ||
|
||
preorder : {A : Type} → Tree A → List A; | ||
preorder (leaf x) := x :: nil; | ||
preorder (node x l r) := | ||
x :: nil ++ preorder l ++ preorder r; | ||
|
||
terminating | ||
sort : {A : Type} → (A → A → Ordering) → List A → List A; | ||
sort _ nil := nil; | ||
sort _ xs@(_ :: nil) := xs; | ||
sort cmp xs := | ||
uncurry | ||
(merge cmp) | ||
(both (sort cmp) (splitAt (div (length xs) 2) xs)); | ||
|
||
printNatListLn : List Nat → IO; | ||
printNatListLn nil := printStringLn "nil"; | ||
printNatListLn (x :: xs) := | ||
printNat x >> printString " :: " >> printNatListLn xs; | ||
|
||
main : IO; | ||
main := | ||
printStringLn "Hello!" | ||
>> printNatListLn (preorder (mirror tree)) | ||
>> printNatListLn (sort compare (preorder (mirror tree))) | ||
>> printNatLn (log2 3) | ||
>> printNatLn (log2 130); | ||
end; | ||
|
||
-- standard library prelude | ||
open import Stdlib.Prelude; | ||
-- for comparisons on natural numbers | ||
open import Stdlib.Data.Nat.Ord; | ||
-- for Ordering | ||
open import Stdlib.Data.Ord; | ||
|
||
even : Nat → Bool; | ||
even zero := true; | ||
even (suc zero) := false; | ||
even (suc (suc n)) := even n; | ||
|
||
even' : Nat → Bool; | ||
even' n := mod n 2 == 0; | ||
|
||
-- base 2 logarithm rounded down | ||
terminating | ||
log2 : Nat → Nat; | ||
log2 n := if (n <= 1) 0 (suc (log2 (div n 2))); | ||
|
||
type Tree (A : Type) := | ||
| leaf : A → Tree A | ||
| node : A → Tree A → Tree A → Tree A; | ||
|
||
mirror : {A : Type} → Tree A → Tree A; | ||
mirror t@(leaf _) := t; | ||
mirror (node x l r) := node x (mirror r) (mirror l); | ||
|
||
tree : Tree Nat; | ||
tree := node 2 (node 3 (leaf 0) (leaf 1)) (leaf 7); | ||
|
||
preorder : {A : Type} → Tree A → List A; | ||
preorder (leaf x) := x :: nil; | ||
preorder (node x l r) := | ||
x :: nil ++ preorder l ++ preorder r; | ||
|
||
terminating | ||
sort : {A : Type} → (A → A → Ordering) → List A → List A; | ||
sort _ nil := nil; | ||
sort _ xs@(_ :: nil) := xs; | ||
sort cmp xs := | ||
uncurry | ||
(merge cmp) | ||
(both (sort cmp) (splitAt (div (length xs) 2) xs)); | ||
|
||
printNatListLn : List Nat → IO; | ||
printNatListLn nil := printStringLn "nil"; | ||
printNatListLn (x :: xs) := | ||
printNat x >> printString " :: " >> printNatListLn xs; | ||
|
||
main : IO; | ||
main := | ||
printStringLn "Hello!" | ||
>> printNatListLn (preorder (mirror tree)) | ||
>> printNatListLn (sort compare (preorder (mirror tree))) | ||
>> printNatLn (log2 3) | ||
>> printNatLn (log2 130); |
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
Oops, something went wrong.