Skip to content

Commit

Permalink
Add a couple more simple language examples to the website
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Sep 25, 2024
1 parent ebbb7f9 commit f03c0ee
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 13 deletions.
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

0 comments on commit f03c0ee

Please sign in to comment.