πŸš€ Getting Started

Set up Mica and write your first program

1

Install Prerequisites

Mica requires a recent stable Rust toolchain. LLVM is bundled with Rust, so no additional native dependencies are needed.

# Install Rust via rustup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Verify installation rustc --version cargo --version

Rust 1.70+ is recommended. Update your toolchain if needed:

rustup update
2

Clone and Build

Clone the Mica repository and build the compiler:

# Clone the repository git clone https://github.com/Sir-Teo/mica.git cd mica # Build the compiler (first build will download dependencies) cargo build --release # The compiler binary will be at: target/release/mica
πŸ’‘ Tip: The first build takes a few minutes as it downloads and compiles dependencies. Subsequent builds are incremental and much faster.
3

Verify Installation

Run the test suite to ensure everything is working correctly:

cargo test

Check the CLI help to see available commands:

cargo run --bin mica -- --help
βœ“ Success! If all tests pass, you're ready to start programming in Mica.
4

Write Your First Program

Create a file named hello.mica:

module hello capability Console func main(using Console console) -> Result[Int, Error] { let hour = 14 let message = match hour { hour if hour < 12 -> "Good morning" hour if hour < 18 -> "Good afternoon" _ -> "Good evening" } console.println(message) Ok(0) }

This program demonstrates:

5

Compile and Run

There are several ways to work with your program:

# View the AST (Abstract Syntax Tree) cargo run --bin mica -- --ast hello.mica # Pretty-print the AST cargo run --bin mica -- --ast --pretty hello.mica # Check for errors (type checking, exhaustiveness) cargo run --bin mica -- --check hello.mica # Lower to HIR (High-level IR) cargo run --bin mica -- --lower hello.mica # View typed SSA IR cargo run --bin mica -- --ir hello.mica # View LLVM scaffold cargo run --bin mica -- --llvm hello.mica # Build a native binary cargo run --bin mica -- --build hello.mica # Compile and run immediately cargo run --bin mica -- --run hello.mica
6

Explore Examples

The examples/ directory contains many sample programs demonstrating different features:

# Algebraic data types cargo run --bin mica -- --run examples/adt.mica # Concurrency with spawn/await cargo run --bin mica -- --run examples/concurrency_pipeline.mica # Generic tree algorithms cargo run --bin mica -- --run examples/generics_tree_algorithms.mica # Effects and resource management cargo run --bin mica -- --run examples/effects_resource_pool.mica # Comprehensive deployment example cargo run --bin mica -- --run examples/comprehensive_deployment.mica

See the Examples page for a complete catalog with descriptions.

7

Development Workflow

For a smooth development experience, consider using cargo-watch:

# Install cargo-watch cargo install cargo-watch # Auto-run on file changes cargo watch -x "run --bin mica -- --run hello.mica"
πŸ’‘ Editor Support: While a dedicated LSP is in development, you can use the CLI tools for quick feedback. The pretty-printer ensures consistent code style.

πŸŽ‰ You're All Set!

You now have a working Mica installation and have written your first program.

Next Steps

πŸ“– Language Tour

Learn the syntax, semantics, and idioms through guided examples

πŸ’» Examples

Browse 20+ runnable programs showcasing all features

πŸ”§ CLI Reference

See real compiler output for every stage of the pipeline

πŸ—οΈ Architecture

Dive into compiler internals and module documentation

πŸ—ΊοΈ Roadmap

Understand the development plan and future features

πŸ› Contribute

Report issues, suggest features, or submit pull requests