# AffineScript in 10 Lessons

**Learn AffineScript from zero to hero in 10 progressive lessons.**

Each lesson builds on the previous one. Complete them in order for the best experience.

---

## Course Overview

| Lesson | Topic | Time | Status |
|--------|-------|------|--------|
| [1](01-hello-affinescript.md) | **Hello AffineScript** - Variables, types, arithmetic | 15 min | ✅ Complete |
| 2 | **Functions & Pattern Matching** - Define functions, match expressions | 20 min | 🔄 In Progress |
| 3 | **Affine Types Basics** - Ownership, move semantics | 25 min | 📝 Planned |
| 4 | **Borrowing & References** - `own` vs `ref` keywords | 25 min | 📝 Planned |
| 5 | **Dependent Types** - Length-indexed vectors, type-level computation | 30 min | 📝 Planned |
| 6 | **Refinement Types** - Compile-time constraints, safe division | 25 min | 📝 Planned |
| 7 | **Effect System** - Tracking I/O, exceptions, purity | 30 min | 📝 Planned |
| 8 | **Row Polymorphism** - Structural typing, flexible records | 25 min | 📝 Planned |
| 9 | **Error Handling** - `Option`, `Result`, try/catch | 30 min | 📝 Planned |
| 10 | **Building Real Programs** - Putting it all together | 40 min | 📝 Planned |

**Total time:** ~4.5 hours

---

## Prerequisites

- Basic programming experience (any language)
- Familiarity with variables, functions, types
- No prior functional programming knowledge required

---

## How to Use These Lessons

### Option 1: Read Online
Each lesson is a markdown file you can read on GitHub.

### Option 2: Interactive Playground
1. Open the [Playground](../../../playground/test.html)
2. Load the lesson example (e.g., `examples/lessons/01_hello.affine`)
3. Follow along by running code as you read

### Option 3: Clone and Experiment
```bash
git clone https://github.com/hyperpolymath/affinescript
cd affinescript
./affinescript examples/lessons/01_hello.affine
```

---

## What You'll Learn

By the end of this course, you'll understand:

✅ **Basic Syntax** - Variables, functions, types
✅ **Affine Types** - Resource safety without complexity
✅ **Dependent Types** - Compile-time correctness proofs
✅ **Refinement Types** - Constrained values (non-zero, positive, etc.)
✅ **Effect System** - Track side effects in types
✅ **Row Polymorphism** - Flexible structural typing
✅ **Error Handling** - Option, Result, exceptions

And you'll be able to:
- Write type-safe, memory-safe programs
- Prove correctness at compile time
- Build real applications with confidence

---

## Learning Path

### Beginner Track (Lessons 1-2)
Start here if you're new to AffineScript or typed languages.

### Intermediate Track (Lessons 3-6)
Core type system features. This is where AffineScript shines.

### Advanced Track (Lessons 7-10)
Real-world programming with effects, errors, and composition.

---

## Additional Resources

- **[What Makes AffineScript Brilliant](../WHAT-MAKES-IT-BRILLIANT.md)** - Why learn this language?
- **[Language Specification](../../specs/affinescript-spec.md)** - Complete formal spec
- **[Playground](../../../playground/test.html)** - Try it in your browser
- **[Examples](../../../examples/)** - More code samples

---

## Get Help

- **Questions?** Open an issue on [GitHub](https://github.com/hyperpolymath/affinescript/issues)
- **Found a bug in lessons?** PRs welcome!
- **Want to contribute?** See [CONTRIBUTING.md](../../../CONTRIBUTING.md)

---

## Start Learning!

**Ready?** → [Lesson 1: Hello AffineScript →](01-hello-affinescript.md)

**Not sure if this is for you?** → [What Makes It Brilliant](../WHAT-MAKES-IT-BRILLIANT.md)
