# hello_wasm

A tiny Gleam program that compiles to WebAssembly and runs under
[wasmtime](https://wasmtime.dev/) via WASI.

The compiler emits a `_start` entry that calls `main` and prints its return
value to stdout (`wasi_snapshot_preview1::fd_write`).

## Run

From this directory (builds the in-repo `gleam` first):

```sh
./run.sh
```

Or step by step:

```sh
# from repo root
cargo build -p gleam

# from this directory
../../target/debug/gleam build
wasmtime build/dev/wasm/hello_wasm/hello_wasm.wasm
```

Expected output:

```text
Hello from Gleam Wasm!
fib(10) = 55
```

You can also call individual exports:

```sh
wasmtime --invoke fib build/dev/wasm/hello_wasm/hello_wasm.wasm 10
# => 55
```

## Notes

- Target is set in `gleam.toml`: `target = "wasm"`.
- `main` must take no arguments. Supported return types for printing: `String`,
  `Int`, and `Bool`.
- No Hex packages yet — the Wasm backend does not implement enough of the
  standard library for typical dependencies.
