mirror of
https://github.com/anoma/juvix.git
synced 2024-09-11 16:26:33 +03:00
Add HelloWorld example and minor other fixes README
This commit is contained in:
parent
4b7fad9304
commit
9543b06cf5
24
Makefile
24
Makefile
@ -3,19 +3,20 @@ PREFIX="$(PWD)/.stack-work/prefix"
|
||||
UNAME := $(shell uname)
|
||||
HLINTQUIET :=
|
||||
|
||||
ASSETS = seating-mascot.051c86a.svg \
|
||||
Seating_Tara_smiling.svg \
|
||||
teaching-mascot.f828959.svg
|
||||
ASSETS = seating-mascot.051c86a.svg \
|
||||
Seating_Tara_smiling.svg \
|
||||
teaching-mascot.f828959.svg
|
||||
|
||||
ORGFILES = $(shell find docs/org -type f -name '*.org')
|
||||
MDFILES:=$(patsubst docs/org/%,docs/md/%,$(ORGFILES:.org=.md))
|
||||
|
||||
EXAMPLEMILESTONE=examples/milestone
|
||||
EXAMPLEHTMLOUTPUT=_docs/examples/html
|
||||
EXAMPLES=ValidityPredicates/SimpleFungibleToken.juvix \
|
||||
TicTacToe/CLI/TicTacToe.juvix \
|
||||
EXAMPLES= HelloWorld/HelloWorld.juvix \
|
||||
Collatz/Collatz.juvix \
|
||||
Fibonacci/Fibonacci.juvix \
|
||||
Collatz/Collatz.juvix
|
||||
TicTacToe/CLI/TicTacToe.juvix \
|
||||
ValidityPredicates/SimpleFungibleToken.juvix
|
||||
|
||||
EXAMPLE_WEBAPP_OUTPUT=_docs/examples/webapp
|
||||
WEBAPP_EXAMPLES=TicTacToe/Web/TicTacToe.juvix
|
||||
@ -66,11 +67,11 @@ $(WEBAPP_EXAMPLES):
|
||||
|
||||
# -- MDBook
|
||||
|
||||
docs/md/README.md :
|
||||
docs/md/README.md : README.org
|
||||
@mkdir -p docs/md
|
||||
@${ORGTOMDPRG} README.org ${ORGOPTS}
|
||||
|
||||
docs/md/changelog.md :
|
||||
docs/md/changelog.md : changelog.org
|
||||
@mkdir -p docs/md
|
||||
@${ORGTOMDPRG} changelog.org ${ORGOPTS}
|
||||
|
||||
@ -79,15 +80,18 @@ docs/md/%.md : docs/org/%.org
|
||||
@mkdir -p $(dir $@)
|
||||
${ORGTOMDPRG} $? ${ORGOPTS}
|
||||
|
||||
.PHONY: markdown-files
|
||||
markdown-files: docs/md/README.md docs/md/changelog.md $(MDFILES)
|
||||
|
||||
.PHONY: markdown-docs
|
||||
markdown-docs: docs/md/README.md docs/md/changelog.md $(MDFILES)
|
||||
markdown-docs: markdown-files
|
||||
@echo "copying assets ..."
|
||||
@mkdir -p docs/md/assets
|
||||
@cp -v $(addprefix assets/,$(ASSETS)) docs/md/assets
|
||||
@mdbook build
|
||||
|
||||
.PHONY: serve-docs
|
||||
serve-docs: $(MDFILES)
|
||||
serve-docs: markdown-files
|
||||
@mdbook serve --open
|
||||
|
||||
# -- Codebase Documentation
|
||||
|
38
README.org
38
README.org
@ -41,6 +41,7 @@ The Juvix language and related tools are documented in [[https://anoma.github.io
|
||||
|
||||
The following links are clickable versions of their corresponding Juvix programs. The HTML output is generated by running =juvix html --recursive FileName.juvix=.
|
||||
|
||||
- [[https://docs.juvix.org/examples/html/HelloWorld/HelloWorld.html][HelloWorld.juvix]]
|
||||
- [[https://docs.juvix.org/examples/html/Fibonacci/Fibonacci.html][Fibonacci.juvix]]
|
||||
- [[https://docs.juvix.org/examples/html/Collatz/Collatz.html][Collatz.juvix]]
|
||||
- [[https://docs.juvix.org/examples/html/TicTacToe/CLI/CLI.TicTacToe.html][TicTacToe.juvix]]
|
||||
@ -105,21 +106,29 @@ the =main= branch on Github.
|
||||
brew install --build-from-source --HEAD juvix --verbose
|
||||
#+end_src
|
||||
|
||||
** Usage Example
|
||||
** The Hello World Example
|
||||
|
||||
In the following example a Juvix file is compiled using the C backend. The
|
||||
result is compiled to WASM using [[https://llvm.org][Clang]] and then executed
|
||||
using [[https://wasmer.io][wasmer]].
|
||||
|
||||
NB: Set the =WASI_SYSROOT_PATH= environment variable to the root of the WASI
|
||||
sysroot. See
|
||||
In the following example a Juvix file is compiled to Wasm. Please check out the documentation
|
||||
[[https://anoma.github.io/juvix/getting-started/dependencies.html][Installing
|
||||
dependencies]] for instructions on how to install the sysroot.
|
||||
dependencies]] for instructions on how to setup your environment for compiling Juvix. You can also run =juvix doctor= to check your system setup.
|
||||
|
||||
#+begin_src shell
|
||||
cd tests/positive/MiniC/HelloWorld
|
||||
juvix compile Input.juvix
|
||||
wasmer Input.wasm
|
||||
-- HelloWorld.juvix
|
||||
module HelloWorld;
|
||||
|
||||
open import Stdlib.Prelude;
|
||||
|
||||
main : IO;
|
||||
main ≔ putStrLn "hello world!";
|
||||
|
||||
end;
|
||||
#+end_src
|
||||
|
||||
Then, run the following commands at the location folder of the file =HelloWorld.juvix=:
|
||||
|
||||
#+begin_src shell
|
||||
juvix compile HelloWorld.juvix
|
||||
wasmer HelloWorld.wasm
|
||||
#+end_src
|
||||
|
||||
You should see the output: =hello world!=
|
||||
@ -170,11 +179,8 @@ For the emacs mode:
|
||||
For the compiler:
|
||||
|
||||
- Init command
|
||||
- New documentation tool. Currently available as an internal command:
|
||||
|
||||
#+begin_src shell
|
||||
juvix internal doc MyFile.juvix
|
||||
#+end_src
|
||||
- New documentation tool: =juvix internal doc MyFile.juvix=
|
||||
#+end_src
|
||||
|
||||
** Community
|
||||
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
- [[./tooling/README.md][Tooling]]
|
||||
- [[./tooling/CLI.md][Command line interface]]
|
||||
- [[./tooling/doctor.md][Doctor]]
|
||||
- [[./tooling/emacs-mode.md][Emacs mode]]
|
||||
- [[./tooling/testing.md][Haskell test suite]]
|
||||
- [[./tooling/doctor.md][Doctor]]
|
||||
|
||||
- [[./notes/README.md][Notes]]
|
||||
- [[./examples/validity-predicates/README.md][Validity predicates]]
|
||||
|
@ -2,11 +2,14 @@
|
||||
|
||||
The following links are clickable versions of their corresponding Juvix programs. The HTML output can be generated by running =juvix html --recursive FileName.juvix=.
|
||||
|
||||
- [[https://anoma.github.io/juvix-stdlib/][The Juvix standard library]]
|
||||
- [[https://docs.juvix.org/examples/html/ValidityPredicates/SimpleFungibleToken.html][SimpleFungibleToken.juvix]]
|
||||
- [[https://docs.juvix.org/examples/html/Collatz/Collatz.html][Collatz.juvix]]
|
||||
- [[https://docs.juvix.org/examples/html/HelloWorld/HelloWorld.html][HelloWorld.juvix]]
|
||||
- [[https://docs.juvix.org/examples/html/Fibonacci/Fibonacci.html][Fibonacci.juvix]]
|
||||
- [[https://docs.juvix.org/examples/html/TicTacToe/CLI/TicTacToe.html][TicTacToe.juvix]]
|
||||
- [[https://docs.juvix.org/examples/html/Collatz/Collatz.html][Collatz.juvix]]
|
||||
- [[https://docs.juvix.org/examples/html/TicTacToe/CLI/CLI.TicTacToe.html][TicTacToe.juvix]]
|
||||
- [[https://docs.juvix.org/examples/html/ValidityPredicates/SimpleFungibleToken.html][SimpleFungibleToken.juvix]]
|
||||
|
||||
The [[https://anoma.github.io/juvix-stdlib/][Juvix standard library]] contains
|
||||
common functions that can be used in Juvix programs.
|
||||
|
||||
** Example Juvix Web apps
|
||||
|
||||
|
0
examples/milestone/Collatz/juvix.yaml
Normal file
0
examples/milestone/Collatz/juvix.yaml
Normal file
0
examples/milestone/Fibonacci/juvix.yaml
Normal file
0
examples/milestone/Fibonacci/juvix.yaml
Normal file
9
examples/milestone/HelloWorld/HelloWorld.juvix
Normal file
9
examples/milestone/HelloWorld/HelloWorld.juvix
Normal file
@ -0,0 +1,9 @@
|
||||
-- HelloWorld.juvix
|
||||
module HelloWorld;
|
||||
|
||||
open import Stdlib.Prelude;
|
||||
|
||||
main : IO;
|
||||
main ≔ putStrLn "hello world!";
|
||||
|
||||
end;
|
0
examples/milestone/HelloWorld/juvix.yaml
Normal file
0
examples/milestone/HelloWorld/juvix.yaml
Normal file
Loading…
Reference in New Issue
Block a user