1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-07 16:22:14 +03:00
juvix/docs/org/quick-start.org
2023-02-09 14:25:36 +01:00

1.9 KiB

Quick Start

<a href="https://github.com/anoma/juvix"> <img align="left" width="200" height="200" alt="Juvix Mascot" src="assets/images/tara-teaching.svg" /> </a>

To install Juvix, follow the instructions in the Installation How-to.

After installation, run juvix --help to see the list of commands.

Run Juvix doctor to check your system setup:

juvix doctor

CLI Usage Examples

Create a new package:

juvix init

Compile a source file into an executable:

juvix compile path/to/source.juvix

Compile a source file into a WebAssembly binary:

juvix compile -t wasm path/to/source.juvix

Launch the REPL:

juvix repl

Typecheck a source file:

juvix typecheck path/to/source.juvix

Generate HTML representations of a source file and its imports:

juvix html --recursive path/to/source.juvix

The Hello World example

This is the Juvix source code of the traditional Hello World program.

-- HelloWorld.juvix
module HelloWorld;

open import Stdlib.Prelude;

main : IO;
main := printStringLn "hello world!";

end;

To compile and run a binary generated by Juvix, save the source code to a file called HelloWorld.juvix and run the following command from the directory containing it:

juvix compile HelloWorld.juvix
./HelloWorld

You should see the output: hello world!

The source code can also be compiled to a WebAssembly binary. This requires some additional setup. See the Installation How-to for more information. You can also run juvix doctor to check your setup.

juvix compile --target wasm HelloWorld.juvix
wasmer HelloWorld.wasm