Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a couple more simple language examples to the website #4

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ Run this command to build and test the main Rust codebase:
cargo test
```

Run this command to make a release build and install it on your `PATH`:

```sh
cargo install --locked --path crates/adroit
```

## JavaScript

We use Bun for our [website][] and for our VS Code extension. To work with the
Expand Down
64 changes: 57 additions & 7 deletions packages/website/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,34 @@ platform from the latest GitHub release:
### macOS Apple Silicon

```sh
sudo curl -L https://github.com/adroit-lang/adroit/releases/download/v0.2.2/adroit-aarch64-apple-darwin -o /usr/local/bin/adroit && sudo chmod +x /usr/local/bin/adroit
sudo curl -L https://github.com/adroit-lang/adroit/releases/download/v0.2.2/adroit-aarch64-apple-darwin -o /usr/local/bin/adroit
sudo chmod +x /usr/local/bin/adroit
```

### macOS Intel

```sh
sudo curl -L https://github.com/adroit-lang/adroit/releases/download/v0.2.2/adroit-x86_64-apple-darwin -o /usr/local/bin/adroit && sudo chmod +x /usr/local/bin/adroit
sudo curl -L https://github.com/adroit-lang/adroit/releases/download/v0.2.2/adroit-x86_64-apple-darwin -o /usr/local/bin/adroit
sudo chmod +x /usr/local/bin/adroit
```

### Linux x64

```sh
sudo curl -L https://github.com/adroit-lang/adroit/releases/download/v0.2.2/adroit-x86_64-unknown-linux-musl -o /usr/local/bin/adroit && sudo chmod +x /usr/local/bin/adroit
sudo curl -L https://github.com/adroit-lang/adroit/releases/download/v0.2.2/adroit-x86_64-unknown-linux-musl -o /usr/local/bin/adroit
sudo chmod +x /usr/local/bin/adroit
```

### Building from source

If none of those prebuilt binaries work for you, you can instead build Adroit
from source by following the [`CONTRIBUTING.md`][] instructions in the GitHub
repo.
from source. First install [Git][] and [Rust][], then run these commands:

```sh
git clone --depth 1 --branch v0.2.2 https://github.com/adroit-lang/adroit.git
cd adroit
cargo install --locked --path crates/adroit
```

## Editor support

Expand All @@ -50,9 +58,50 @@ adroit --help
Currently Adroit is in the early stages of development and has no interpreter
and no compiler backend, so there is no way to run an Adroit program.

By convention, Adroit source file names end with the `.adroit` extension.

## Language

Here is an example function implementing matrix multiplication in Adroit:
Here is an Adroit function that takes a floating-point number as input, and
returns the square of that number as output:

```adroit
def square(x: Float): Float = x * x
```

Within the body of a function, you can use `let` to give an intermediate value a
name; then you write the return value of the function after all your
`let`-bindings:

```adroit
def foo(x: Float, y: Float): Float =
let a = x + y
let b = x * y
a / b
```

Indentation is never significant in Adroit, but newlines are sometimes
significant; as you can see above, you can end a `let`-binding with a newline,
but if you'd prefer to put more on one line, you can instead use a semicolon:

```adroit
def tesseract(x: Float): Float = let y = x * x; y * y
```

Functions can be generic:

```adroit
def identity[T](x: T): T = x
```

Adroit currently has three standard library modules:

- `"array"`
- `"autodiff"`
- `"math"`

Here is an example using a couple functions from the `"array"` module to
implement matrix multiplication:

```adroit
import "array" use for, sum
Expand All @@ -65,5 +114,6 @@ def mmul[M, N, P](
sum(for k => a[i, k] * b[k, j])
```

[`CONTRIBUTING.md`]: https://github.com/adroit-lang/adroit/blob/main/CONTRIBUTING.md
[from the VS Code Marketplace]: https://marketplace.visualstudio.com/items?itemName=adroit-lang.adroit-vscode
[git]: https://git-scm.com/downloads
[rust]: https://www.rust-lang.org/tools/install