Skip to content

zio/zionomicon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

326 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zionomicon Solutions

A comprehensive collection of exercises and solutions for learning ZIO — a Scala library for asynchronous and concurrent programming.

This repository serves as a hands-on companion to the Zionomicon Book, providing solutions to the exercises in each chapter.

What is ZIO?

ZIO is a zero-dependency Scala library that provides:

  • Powerful async/concurrent runtime built on fibers (lightweight threads)
  • Functional error handling with typed error channels
  • Resource safety with automatic cleanup guarantees
  • Dependency injection through type-level composition
  • Software Transactional Memory (STM) for safe concurrent access

How to Use This Repository

  1. Start with exercises: Look in src/main/scala/zionomicon/exercises/ for skeleton code with problem statements in Scaladoc comments
  2. Attempt the exercises: Try to implement the solutions yourself
  3. Check solutions: Compare your work against src/main/scala/zionomicon/solutions/
  4. Read explanations: Each solution includes detailed comments explaining the approach and key concepts

Overview

Fundamentals (Chapters 1–4)

  • Chapter 1: First steps with ZIO — basic effects, main function, error handling (Exercises | Solutions)
  • Chapter 2: Testing ZIO programs — test assertions, test services (Exercises | Solutions)
  • Chapter 3: The ZIO error model — typed errors, exception handling (Exercises | Solutions)
  • Chapter 4: Essentials — integrating with ZIO, database operations, legacy code integration (Exercises | Solutions)

Parallelism & Concurrency (Chapters 5–6, 8)

  • Chapter 5: The fiber model — lightweight concurrency, fiber creation and inspection (Exercises | Solutions)
  • Chapter 6: Concurrent operators — race, zip, foreach parallel execution (Exercises | Solutions)
  • Chapter 8: Interruption in depth — cancellation, finalizers, safe shutdown (Exercises | Solutions)

Concurrent Data Structures (Chapters 9–15)

Dependency Injection & Configuration (Chapters 17, 19–20)

  • Chapter 17: Dependency injection essentials — R type parameter, layers (Exercises | Solutions)
  • Chapter 19: Contextual data types — ZIO environment composition (Exercises | Solutions)
  • Chapter 20: Configuring ZIO applications — configuration management (Exercises | Solutions)

Software Transactional Memory (Chapters 21–23)

Streams & Channels (Chapters 29–32)

  • Chapter 29: ZChannel — low-level channel abstraction, composing channels (Exercises | Solutions)
  • Chapter 30: Transforming streams — mapping, filtering, folding stream data (Exercises | Solutions)
  • Chapter 31: Combining streams — merging, zipping, and correlating multiple streams (Exercises | Solutions)
  • Chapter 32: Streaming pipelines — building data processing pipelines with streams (Exercises | Solutions)

Communication & Protocols (Chapters 34–35)

  • Chapter 34: Schemas — the anatomy of data types, schema design patterns (Exercises | Solutions)
  • Chapter 35: Communication protocols — ZIO HTTP, RESTful APIs, serialization (Exercises | Solutions)

Resilience, Runtime & Observability (Chapters 24, 26, 37, 39)

  • Chapter 24: Retries — schedules, exponential backoff, adaptive policies (Exercises | Solutions)
  • Chapter 26: Best practices — design patterns and code organization (Exercises | Solutions)
  • Chapter 37: ZIO runtime — executor configuration, thread pool management, runtime system (Exercises | Solutions)
  • Chapter 39: Observability — metrics, monitoring, Prometheus and StatsD integration (Exercises | Solutions)

Appendices

  • Appendix C: Functional design — function composition, functional abstractions (Exercises | Solutions)

Building and Running

Prerequisites

  • Scala 2.13
  • SBT (Simple Build Tool)

Compile

sbt compile

Run Tests

sbt test

Run Benchmarks

sbt jmh:run

Dependencies

The project uses:

  • ZIO 2.1.21 — Core async/concurrent runtime
  • zio-config — Configuration management
  • zio-http — HTTP server/client utilities
  • zio-test — Testing framework
  • zio-prelude — Validation and type safety utilities
  • doobie — Database access (with SQLite driver)
  • JMH — Benchmarking (Java Microbenchmark Harness)

See build.sbt for full dependency list.

Contributing

This is a learning resource maintained in sync with the upstream Zionomicon. Contributions are welcome — fixes, additional exercises, and clarifications improve the learning experience for everyone.

About

Exercises for Zionomicon

Topics

Resources

Stars

37 stars

Watchers

6 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages