SagaSaga
Guide

The Saga Guide

Learn Saga from the ground up, from Hello World to effects, handlers, and concurrency.

Using Saga with an AI assistant? Drop /llms.txt into context for an index of guides, or /llms-full.txt for the whole guide concatenated.
01

Language Tour

A quick overview of everything Saga offers, in one page.

02

Installation

Install Erlang, the Saga compiler, and set up your editor.

03

Getting Started

Your first Saga program, basic commands, and a quick taste of the language.

04

Basics

Bindings, primitive types, operators, blocks, strings, and pipes.

05

Functions

Definitions, annotations, pub/private, lambdas, currying, and composition.

06

Types

ADTs, records, tuples, type parameters, opaque types, and dictionaries.

07

Pattern Matching

Case expressions, guards, destructuring, list/record/string patterns, and exhaustiveness.

08

Control Flow

do...else for sequential pattern binding, and list comprehensions.

09

Traits

Type-driven dispatch with Show, Eq, Ord. where clauses, supertraits, and deriving.

10

Effects & Handlers

Declaring effects, performing with !, writing handlers, resume, and abort.

11

Error Handling

The Fail effect, to_result, Result vs Fail philosophy, panic, and catch_panic.

12

Handler Patterns

Named, inline, let-bound, and factory handlers. Stacking, ordering, and the return clause.

13

Advanced Effects

Row polymorphism, effect signatures on higher-order functions, subtyping, and multishot continuations.

14

Testing

Effect-based testing with describe, test, handler swapping, and CI integration.

15

Project & Modules

Project layout, project.toml configuration, module declarations, imports, pub visibility, and qualified access.

16

Ecosystem

Hex, git, and path dependencies. saga install, the lockfile, transitive deps, NIF compilation with rebar3, and the dep cache.

17

Concurrency & Actors

The Actor effect: spawn, send, receive. Isolation and message passing on the BEAM.

18

Supervision

Supervision as a handler pattern. Restart strategies, backoff, and let-it-crash.

19

BitStrings

Binary construction, pattern matching, segment specifiers, and Std.BitString.

20

Refs

Atomic references for controlled mutable state. When to use refs vs recursion.

21

Interop

Calling Erlang, Hex dependencies, git deps, and project.toml configuration.

22

Generic Deriving

Make your own traits derivable. The Generic representation, building-block instances, and the rules a derivable trait must follow.