How to Build Your First App

This guide covers two flows:

  1. Build and run a single Eta app package.
  2. Build an app + library in one workspace (end-to-end).

Prerequisites

eta --version

1) Build your first app

Create a new app package:

eta new hello_app --bin
cd hello_app

Edit src/hello_app.eta:

(module hello_app
  (import std.io)
  (begin
    (defun main (args)
      (println "hello from my first eta app"))))

Build and run:

eta build
eta run

Expected output:

hello from my first eta app

2) Build an app with a library (end-to-end)

Create a workspace with two member packages

mkdir first_workspace
cd first_workspace
eta new mathx --lib
eta new myapp --bin

Create a workspace root manifest at first_workspace/eta.toml:

[workspace]
members = ["mathx", "myapp"]
default-members = ["myapp"]

Implement the library package

Edit mathx/src/mathx.eta:

(module mathx
  (export square cube)
  (import std.math)
  (begin
    (defun square (x) (* x x))
    (defun cube (x) (* x x x))))

Add the library dependency to the app package

cd myapp
eta add mathx --path ../mathx

Edit src/myapp.eta:

(module myapp
  (import std.io)
  (import mathx)
  (begin
    (defun main (args)
      (println (square 7)))))

Build, test, and run from the workspace root

cd ..
eta test --workspace
eta build --workspace
eta run -p myapp

Expected output:

49

Inspect the resolved dependency graph:

eta tree --workspace

In workspace mode, build artifacts are written under: .eta/target/<profile>/<member-name>/... at the workspace root.