# ZIO > Type-safe, composable asynchronous and concurrent programming for Scala. This file contains links to documentation sections following the llmstxt.org standard. ## Table of Contents - [Basic Concurrency](https://zio.dev/overview/basic-concurrency.md): ZIO is a highly concurrent framework, powered by _fibers_, which are lightweight virtual threads that achieve massive scalability compared to threa... - [Basic Operations](https://zio.dev/overview/basic-operations.md): Like the `String` data type, as well as the collection data types in Scala (such as `List`, `Map`, and `Set`), ZIO effects are _immutable_, and can... - [Creating Effects](https://zio.dev/overview/creating-effects.md): This section explores some of the common ways to create ZIO effects from values, from computations, and from common Scala data types. - [Handling Errors](https://zio.dev/overview/handling-errors.md): ZIO effects may fail due to foreseen or unforeseen problems. In order to help you build robust applications, ZIO tracks foreseen errors at compile-... - [Handling Resources](https://zio.dev/overview/handling-resources.md): Ensuring that your applications never leak resources is one of the keys to maximizing application throughput, minimizing latency, and maximizing pe... - [Getting Started with ZIO](https://zio.dev/overview/getting-started.md): The `zio-knowledge` skill teaches your coding agent to fetch live documentation from zio.dev before answering any ZIO question — so you always get ... - [Performance](https://zio.dev/overview/performance.md): ZIO is a high-performance framework that is powered by non-blocking fibers (which will move to _virtual threads_ under Loom). - [Platforms](https://zio.dev/overview/platforms.md): ZIO provides a consistent interface across platforms to the maximum extent possible, allowing developers to write code once and deploy it everywher... - [Running Effects](https://zio.dev/overview/running-effects.md): ZIO effects are precise plans that _describe_ a computation or interaction. Ultimately, every effect must be _executed_ by the ZIO runtime. - [Summary](https://zio.dev/overview/summary.md): ZIO is a next-generation framework for building cloud-native applications on the JVM. With a beginner-friendly yet powerful functional core, ZIO le... - [Architectural Patterns](https://zio.dev/reference/architecture/architectural-patterns.md): In this section, we are going to talk about the design elements of a ZIO application and the ZIO idiomatic way of structuring codes to write ZIO ap... - [Functional Design Patterns](https://zio.dev/reference/architecture/functional-design-patterns.md): When designing an API, there are patterns that are commonly used. In this section, we are going to talk about some of these patterns: - [Non-functional Requirements](https://zio.dev/reference/architecture/non-functional-requirements.md): Designing and architecting a software system is a complex task. We should consider both the functional and non-functional requirements of the system. - [Programming Paradigms in ZIO](https://zio.dev/reference/architecture/programming-paradigms-in-zio.md): It is important to realize that the programming paradigm used to write a software system has a significant impact on its design and architecture. I... - [Hub](https://zio.dev/reference/concurrency/hub.md): A `Hub` is an asynchronous message hub. Publishers can publish messages to the hub and subscribers can subscribe to receive messagesfrom the hub. - [Introduction to Concurrent Programming in ZIO](https://zio.dev/reference/concurrency/index.md): Most of the time in concurrent programming we have a single state that we need to read and update concurrently. When we have multiple fibers readin... - [Promise](https://zio.dev/reference/concurrency/promise.md): A `Promise[E, A]` is a variable of `IO[E, A]` type that can be set exactly once. - [Queue](https://zio.dev/reference/concurrency/queue.md): `Queue` is a lightweight in-memory queue built on ZIO with composable and transparent back-pressure. It is fully asynchronous (no locks or blocking... - [Ref](https://zio.dev/reference/concurrency/ref.md): `Ref[A]` models a **mutable reference** to a value of type `A` in which we can store **immutable** data. The two basic operations are `set`, which ... - [Ref.Synchronized](https://zio.dev/reference/concurrency/refsynchronized.md): `Ref.Synchronized[A]` models a **mutable reference** to a value of type `A` in which we can store **immutable** data, and update it atomically **an... - [Semaphore](https://zio.dev/reference/concurrency/semaphore.md): A `Semaphore` datatype which allows synchronization between fibers with the `withPermit` operation, which safely acquires and releases a permit. - [Introduction to Configuration in ZIO](https://zio.dev/reference/configuration/index.md): Configuration is a core concern for any cloud-native application. So ZIO ships with built-in support for configuration by providing a front-end for... - [Automatic ZLayer Derivation](https://zio.dev/reference/contextual/automatic-zlayer-derivation.md): ZIO's `ZLayer` is a powerful tool for building modular, testable, and composable applications. With the `ZLayer.derive` - [Introduction to the ZIO's Contextual Data Types](https://zio.dev/reference/contextual/index.md): ZIO provides a contextual abstraction that encodes the environment of the running effect. This means, every effect can work within a specific conte... - [Layer](https://zio.dev/reference/contextual/layer.md): `Layer[+E, +ROut]` is a type alias for `ZLayer[Any, E, ROut]`, which represents a layer that doesn't require any services, it may fail with an erro... - [RLayer](https://zio.dev/reference/contextual/rlayer.md): `RLayer[-RIn, +ROut]` is a type alias for `ZLayer[RIn, Throwable, ROut]`, which represents a layer that requires `RIn` as its input, it may fail wi... - [TaskLayer](https://zio.dev/reference/contextual/tasklayer.md): `TaskLayer[+ROut]` is a type alias for `ZLayer[Any, Throwable, ROut]`, which represents a layer that doesn't require any services as its input, it ... - [ULayer](https://zio.dev/reference/contextual/ulayer.md): `ULayer[+ROut]` is a type alias for `ZLayer[Any, Nothing, ROut]`, which represents a layer that doesn't require any services as its input, it can't... - [URLayer](https://zio.dev/reference/contextual/urlayer.md): `URLayer[-RIn, +ROut]` is a type alias for `ZLayer[RIn, Nothing, ROut]`, which represents a layer that requires `RIn` as its input, it can't fail, ... - [ZEnvironment](https://zio.dev/reference/contextual/zenvironment.md): A `ZEnvironment[R]` is a built-in type-level map for the `ZIO` data type which is responsible for maintaining the environment of a `ZIO` effect. Th... - [ZIO Environment Use-cases](https://zio.dev/reference/contextual/zio-environment-use-cases.md): ZIO Environment allows us to describe workflows which carry some context that is used in the course of executing the workflow. This context can be ... - [ZLayer](https://zio.dev/reference/contextual/zlayer.md): A `ZLayer[-RIn, +E, +ROut]` describes a layer of an application: every layer in an application requires some services as input `RIn` and produces s... - [Introduction to ZIO's Control Flow Operators](https://zio.dev/reference/control-flow/index.md): Although we have access to built-in Scala control flow structures, ZIO has several control flow combinators. In this section, we are going to intro... - [Cause](https://zio.dev/reference/core/cause.md): The `ZIO[R, E, A]` effect is polymorphic in values of type `E` and we can work with any error type that we want, but there is a lot of information ... - [Exit](https://zio.dev/reference/core/exit.md): An `Exit[E, A]` value describes how fibers end life. It has two possible values: - [Core Data Types](https://zio.dev/reference/core/index.md): In this section we are going to talk about the basic data types that are required to build a ZIO application: - [Runtime](https://zio.dev/reference/core/runtime.md): A `Runtime[R]` is capable of executing tasks within an environment `R`. - [IO](https://zio.dev/reference/core/zio/io.md): `IO[E, A]` is a type alias for `ZIO[Any, E, A]`, which represents an effect that has no requirements, and may fail with an `E`, or succeed with an ... - [RIO](https://zio.dev/reference/core/zio/rio.md): `RIO[R, A]` is a type alias for `ZIO[R, Throwable, A]`, which represents an effect that requires an `R`, and may fail with a `Throwable` value, or ... - [Task](https://zio.dev/reference/core/zio/task.md): `Task[A]` is a type alias for `ZIO[Any, Throwable, A]`, which represents an effect that has no requirements, and may fail with a `Throwable` value,... - [UIO](https://zio.dev/reference/core/zio/uio.md): `UIO[A]` is a type alias for `ZIO[Any, Nothing, A]`, which represents an **Unexceptional** effect that doesn't require any specific environment, an... - [URIO](https://zio.dev/reference/core/zio/urio.md): `URIO[R, A]` is a type alias for `ZIO[R, Nothing, A]`, which represents an effect that requires an `R`, and cannot fail, but can succeed with an `A`. - [ZIO](https://zio.dev/reference/core/zio/zio.md): A `ZIO[R, E, A]` value is an immutable value that lazily describes a workflow or job. The workflow requires some environment `R`, and may fail with... - [ZIOApp](https://zio.dev/reference/core/zioapp.md): The `ZIOApp` trait is an entry point for a ZIO application that allows sharing layers between applications. It also - [Automatic Layer Construction](https://zio.dev/reference/di/automatic-layer-construction.md): ZIO also has an automatic layer construction facility, which takes care of building dependency graphs from the individual layers and building block... - [Building Dependency Graph](https://zio.dev/reference/di/building-dependency-graph.md): We have two options to build a dependency graph: - [Getting Started With Dependency Injection in ZIO](https://zio.dev/reference/di/dependency-injection-in-zio.md): :::caution - [Layers Are Shared by Default](https://zio.dev/reference/di/dependency-memoization.md): Layer memoization allows a layer to be created once and used multiple times in the dependency graph. So if we use the same layer twice, e.g. `(a >>... - [Dependency Propagation](https://zio.dev/reference/di/dependency-propagation.md): When we write an application, our application has a lot of dependencies. We need a way to provide implementations and to feed and propagate all dep... - [Examples](https://zio.dev/reference/di/examples.md): In the following example, we have an application that requires `AppConfig` layer, which itself requires `DBConfig` and `ServerConfig` layers: - [Introduction to Dependency Injection in ZIO](https://zio.dev/reference/di/index.md): When we implement a service, we might need to use other services. So a dependency is just another service that is required to fulfill its functiona... - [Manual Layer Construction](https://zio.dev/reference/di/manual-layer-construction.md): We said that we can think of the `ZLayer` as a more powerful _constructor_. Constructors are not composable, because they are not values. While a c... - [Motivation](https://zio.dev/reference/di/motivation.md): :::caution - [Overriding Dependency Graph](https://zio.dev/reference/di/overriding-dependency-graph.md): We can create a ZIO application by providing a local or a global environment, or a combination: - [Providing Different Implementation of a Service](https://zio.dev/reference/di/providing-different-implementation-of-a-service.md): One of the benefits of using dependency injection is that, we can write our application in a way that without modifying the application logic, we c... - [ZLayer: Constructor as a Value](https://zio.dev/reference/di/zlayer-constructor-as-a-value.md): Before jumping into the next section, which will explain dependency injection in ZIO, let's take a look at the philosophy behind the `ZLayer` data ... - [Model Domain Errors Using Algebraic Data Types](https://zio.dev/reference/error-management/best-practices/algebraic-data-types.md): It is best to use _algebraic data types (ADTs)_ when modeling errors within the same domain or subdomain. - [Don't Type Unexpected Errors](https://zio.dev/reference/error-management/best-practices/unexpected-errors.md): When we first discover typed errors, it may be tempting to put every error into the error type parameter. That is a mistake because we can't recove... - [Don't Reflexively Log Errors](https://zio.dev/reference/error-management/best-practices/logging-errors.md): In modern async concurrent applications with a lot of subsystems, if we do not type errors, we are not able to see what section of our code fails w... - [Use Union Types to Be More Specific About Error Types](https://zio.dev/reference/error-management/best-practices/union-types.md): In Scala 3, we have an exciting new feature called union types. By using the union operator, we can encode multiple error types. Using this facilit... - [Imperative vs. Declarative Error Handling](https://zio.dev/reference/error-management/imperative-vs-declarative.md): To figure out the benefit of typed errors in declarative error handling, we need to understand the drawbacks of the imperative approach and then se... - [Error Accumulation](https://zio.dev/reference/error-management/error-accumulation.md): Sequential combinators such as `ZIO#zip` and `ZIO.foreach` stop when they reach the first error and return immediately. So their policy on error ma... - [Examples](https://zio.dev/reference/error-management/examples.md): Let's write an application that takes numerator and denominator from the user and then print the result back to the user: - [Exceptional and Unexceptional Effects](https://zio.dev/reference/error-management/exceptional-and-unexceptional-effects.md): Besides the `IO` type alias, ZIO has four different type aliases which can be categorized into two different categories: - [Expected and Unexpected Errors](https://zio.dev/reference/error-management/expected-and-unexpected-errors.md): Inside an application, there are two distinct categories of errors: - [Introduction to Error Management in ZIO](https://zio.dev/reference/error-management/index.md): As well as providing first-class support for typed errors, ZIO has a variety of facilities for catching, propagating, and transforming errors in a ... - [Chaining Effects Based on Errors](https://zio.dev/reference/error-management/operations/chaining-effects-based-on-errors.md): Unlike `ZIO#flatMap` the `ZIO#flatMapError` combinator chains two effects, where the second effect is dependent on the error channel of the first e... - [Converting Defects to Failures](https://zio.dev/reference/error-management/operations/converting-defects-to-failures.md): Both `ZIO#resurrect` and `ZIO#absorb` are symmetrical opposite of the `ZIO#orDie` operator. The `ZIO#orDie` takes failures from the error channel a... - [Error Refinement](https://zio.dev/reference/error-management/operations/error-refinement.md): ZIO has some operators useful for converting defects into failures. So we can take part in non-recoverable errors and convert them into the typed e... - [Exposing Errors in The Success Channel](https://zio.dev/reference/error-management/operations/exposing-errors-in-the-success-channel.md): Before taking into `ZIO#either` and `ZIO#absolve`, let's see their signature: - [Exposing the Cause in The Success Channel](https://zio.dev/reference/error-management/operations/exposing-the-cause-in-the-success-channel.md): Using the `ZIO#cause` operation we can expose the cause, and then by using `ZIO#uncause` we can reverse this operation: - [Filtering the Success Channel](https://zio.dev/reference/error-management/operations/filtering-the-success-channel.md): ZIO has a variety of operators that can filter values on the success channel based on a given predicate, and if the predicate fails, we can use dif... - [Flattening Optional Error Types](https://zio.dev/reference/error-management/operations/flattening-optional-error-types.md): If we have an optional error of type `E` in the error channel, we can flatten it to the `E` type using the `ZIO#flattenErrorOption` operator: - [Flipping Error and Success Channels](https://zio.dev/reference/error-management/operations/flipping-error-and-success-channels.md): Sometimes, we would like to apply some methods on the error channel which are specific for the success channel, or we want to apply some methods on... - [Map Operations](https://zio.dev/reference/error-management/operations/map-operations.md): Other than `ZIO#map` and `ZIO#flatMap`, ZIO has several other operators to manage errors while mapping: - [Merging the Error Channel into the Success Channel](https://zio.dev/reference/error-management/operations/merging-the-error-channel-into-the-success-channel.md): With `ZIO#merge` we can merge the error channel into the success channel: - [Rejecting Some Success Values](https://zio.dev/reference/error-management/operations/rejecting-some-success-values.md): We can reject some success values using the `ZIO#reject` operator: - [Tapping Errors](https://zio.dev/reference/error-management/operations/tapping-errors.md): Like [tapping for success values](../../core/zio/zio.md#tapping) ZIO has several operators for tapping error values. So we can peek into failures o... - [Zooming In on Nested Values](https://zio.dev/reference/error-management/operations/zooming-in-on-nested-values.md): We can extract a value from a Some using `ZIO#some` and then we can unsome it again using `ZIO#unsome`: - [Catching](https://zio.dev/reference/error-management/recovering/catching.md): If we want to catch and recover from all _typed error_ and effectfully attempt recovery, we can use the `ZIO#catchAll` operator: - [Fallback](https://zio.dev/reference/error-management/recovering/fallback.md): We can try one effect, or if it fails, try another effect with the `orElse` combinator: - [Folding](https://zio.dev/reference/error-management/recovering/folding.md): Scala's `Option` and `Either` data types have `fold`, which let us handle both failure and success at the same time. In a similar fashion, `ZIO` ef... - [Retrying](https://zio.dev/reference/error-management/recovering/retrying.md): When we are building applications we want to be resilient in the face of a transient failure. This is where we need to retry to overcome these fail... - [Sandboxing](https://zio.dev/reference/error-management/recovering/sandboxing.md): We know that a ZIO effect may fail due to a failure, a defect, a fiber interruption, or a combination of these causes. So a ZIO effect may contain ... - [Timing out](https://zio.dev/reference/error-management/recovering/timing-out.md): ZIO lets us timeout any effect using the `ZIO#timeout` method, which returns a new effect that succeeds with an `Option`. A value of `None` indicat... - [Sequential and Parallel Errors](https://zio.dev/reference/error-management/sequential-and-parallel-errors.md): A simple and regular ZIO application usually fails with one error, which is the first error encountered by the ZIO runtime: - [Typed Errors Guarantees](https://zio.dev/reference/error-management/typed-errors-guarantees.md): **Typed errors don't guarantee the absence of defects and interruptions.** Having an effect of type `ZIO[R, E, A]`, means it can fail because of so... - [Defects](https://zio.dev/reference/error-management/types/defects.md): By providing a `Throwable` value to the `ZIO.die` constructor, we can describe a dying effect: - [Failures](https://zio.dev/reference/error-management/types/failures.md): When writing ZIO application, we can model a failure, using the `ZIO.fail` constructor: - [Fatal Errors](https://zio.dev/reference/error-management/types/fatals.md): In ZIO on the JVM platform, the `VirtualMachineError` and all its subtypes are the only errors considered fatal by the ZIO runtime. So if during th... - [Three Types of Errors](https://zio.dev/reference/error-management/types/index.md): We should consider three types of errors when writing ZIO applications: - [Fiber](https://zio.dev/reference/fiber/fiber.md.md): To perform an effect without blocking the current process, we can use fibers, which are a lightweight concurrency mechanism. - [FiberId](https://zio.dev/reference/fiber/fiberid.md): `FiberId` is the identity of a [Fiber](fiber.md), described by a globally unique sequence number and the time when it began life: - [Fiber.Status](https://zio.dev/reference/fiber/fiberstatus.md): `Fiber.Status` describes the current status of a [Fiber](fiber.md). - [Introduction to ZIO Fibers](https://zio.dev/reference/fiber/index.md): A Fiber can be thought of as a virtual thread. A Fiber is the analog of a Java thread (`java.lang.Thread`), but it performs much better. Fibers are... - [Introduction](https://zio.dev/reference/index.md): ZIO contains a few data types that can help you solve complex problems in asynchronous and concurrent programming. ZIO data types categorize into t... - [Introduction to ZIO's Interruption Model](https://zio.dev/reference/interruption/index.md): While developing concurrent applications, there are several cases that we need to _interrupt_ the execution of other fibers, for example: - [Introduction to Logging in ZIO](https://zio.dev/reference/observability/logging.md): ZIO supports a lightweight built-in logging facade that standardizes the interface to logging functionality. So it doesn't replace existing logging... - [Counter](https://zio.dev/reference/observability/metrics/counter.md): A `Counter` is a metric representing a single numerical value that may be incremented over time. A typical use of this metric would be to track the... - [Frequency](https://zio.dev/reference/observability/metrics/frequency.md): A `Frequency` represents the number of occurrences of specified values. We can think of a `Frequency` as a set of counters associated with each val... - [Gauge](https://zio.dev/reference/observability/metrics/gauge.md): A `Gauge` is a metric representing a single numerical value that may be _set_ or _adjusted_. A typical use of this metric would be to track the cur... - [Histogram](https://zio.dev/reference/observability/metrics/histogram.md): A `Histogram` is a metric representing a collection of numerical with the distribution of the cumulative values over time. They organize a range of... - [Introduction to ZIO Metrics](https://zio.dev/reference/observability/metrics/index.md): In highly concurrent applications, things are interconnected, so maintaining such a setup to run smoothly and without application downtimes is very... - [JVM Metrics](https://zio.dev/reference/observability/metrics/jvm.md): ZIO has built-in support for collecting JVM Metrics. These metrics are a direct port of the JVM metrics provided by the [Prometheus Java Hotspot li... - [MetricLabel](https://zio.dev/reference/observability/metrics/metriclabel.md): A `MetricLabel` metadata represents a key-value pair that allows analyzing metrics at an additional level of granularity. For example, if a metric ... - [Summary](https://zio.dev/reference/observability/metrics/summary.md): A `Summary` represents a sliding window of a time series along with metrics for certain percentiles of the time series, referred to as quantiles. - [Supervisor](https://zio.dev/reference/observability/supervisor.md): A `Supervisor[A]` is allowed to supervise the launching and termination of fibers, producing some visible value of type `A` from the supervision. - [Introduction to Tracing in ZIO](https://zio.dev/reference/observability/tracing.md): Although logs and metrics are useful for understanding the behavior of individual services, they are not enough to provide a complete overview of t... - [Introduction to Resource Management in ZIO](https://zio.dev/reference/resource/index.md): When we are writing a long-lived application, resource management is very important. Proper resource management is vital to any large-scale applica... - [Scope](https://zio.dev/reference/resource/scope.md): The `Scope` data type is the foundation of safe and composable resources handling in ZIO. - [ScopedRef: Mutable Reference For Resources](https://zio.dev/reference/resource/scopedref.md): `ScopedRef` is a resourceful version of `Ref` data type. So it is a `Ref` for resourceful effects. - [ZKeyedPool](https://zio.dev/reference/resource/zkeyedpool.md): The `ZKeyedPool[+Err, -Key, Item]` is a pool of items of type `Item` that are associated with a key of type `Key`. An attempt to get an item from a... - [ZPool](https://zio.dev/reference/resource/zpool.md): A `ZPool[E, A]` is a pool of items of type `A`, each of which may be associated with the acquisition and release of resources. An attempt to get an... - [Built-in Schedules](https://zio.dev/reference/schedule/built-in-schedules.md): Returns a schedule that repeats one time, producing the specified constant value: - [Schedule Combinators](https://zio.dev/reference/schedule/combinators.md): Schedules define stateful, possibly effectful, recurring schedules of events, and compose in a variety of ways. Combinators allow us to take schedu... - [Examples](https://zio.dev/reference/schedule/examples.md): Let's try some example of creating and combining schedules. - [Introduction to Scheduling ZIO Effects](https://zio.dev/reference/schedule/index.md): A `Schedule[Env, In, Out]` is an **immutable value** that **describes** a recurring effectful schedule, which runs in some environment `Env`, after... - [Repetition](https://zio.dev/reference/schedule/repetition.md): In the case of repetition, ZIO has a `ZIO#repeat` function, which takes a schedule as a repetition policy and returns another effect that describes... - [Retrying](https://zio.dev/reference/schedule/retrying.md): In the case of retrying, ZIO has a `ZIO#retry` function, which takes a schedule as a repetition policy and returns another effect that describes an... - [Accessor Methods (deprecated)](https://zio.dev/reference/service-pattern/accessor-methods.md): Accessor methods are little helper methods that lookup a service from the environment, and then forward your call to - [Defining Polymorphic Services in ZIO](https://zio.dev/reference/service-pattern/defining-polymorphic-services-in-zio.md): As we discussed [here](../contextual/zenvironment.md), the `ZEnvironment`, which is the underlying data type used by `ZLayer`, is backed by a type-... - [Introduction to Writing ZIO Services](https://zio.dev/reference/service-pattern/introduction.md): Defining services in ZIO is not very different from object-oriented style, it has the same principle: coding to an interface, not an implementation... - [Introduction to Reloadable Services](https://zio.dev/reference/service-pattern/reloadable-services.md): Reloadable services are a feature in ZIO that allow us to reload services when necessary. With ZIO When we reload a service, it will automatically ... - [The Four Elements of Service Pattern](https://zio.dev/reference/service-pattern/service-pattern.md): Writing services in ZIO using the _Service Pattern_ is very similar to the object-oriented way of defining services. We use scala traits to define ... - [The Three Laws of ZIO Environment](https://zio.dev/reference/service-pattern/the-three-laws-of-zio-environment.md): When we are working with the ZIO environment, one question might arise: "When should we use environment and when do we need to use constructors?". - [Clock](https://zio.dev/reference/services/clock.md): Clock service contains some functionality related to time and scheduling. - [Console](https://zio.dev/reference/services/console.md): The Console service contains simple I/O operations for reading/writing strings from/to the standard input, output, and error console. - [Introduction to ZIO's Built-in Services](https://zio.dev/reference/services/index.md): ZIO already provides four built-in services: - [Random](https://zio.dev/reference/services/random.md): Random service provides utilities to generate random numbers. It's a functional wrapper of `scala.util.Random`. This service contains various diffe... - [System](https://zio.dev/reference/services/system.md): System service contains several useful functions related to system environments and properties. Both of **system environments** and **system proper... - [Fiber-local State](https://zio.dev/reference/state-management/fiber-local-state.md): Both the `FiberRef` and `ZState` data types are state management tools that are scoped to a certain fiber. Their values are only accessible within ... - [FiberRef: Introduction to Fiber-local Storage](https://zio.dev/reference/state-management/fiberref.md): `FiberRef` is a data structure for managing and accessing thread-local values within a ZIO fiber. Thread-local storage (TLS) is a mechanism that pr... - [Global Shared State Using Ref](https://zio.dev/reference/state-management/global-shared-state.md): One of the common use cases for `Ref` is to manage the state of applications, especially in concurrent environments. We can use the `Ref` data type... - [Introduction to State Management in ZIO](https://zio.dev/reference/state-management/index.md): When we write a program, more often we need to keep track of some sort of state during the execution of the program. If an object has a state, its ... - [State Management Using Recursion](https://zio.dev/reference/state-management/recursion.md): This is a very common pattern to use variables to keep track of the state. For example, to calculate the length of a list, we can store intermediat... - [ZState](https://zio.dev/reference/state-management/zstate.md): `ZState[S]` models a value of type `S` that can be read from and written to during the execution of an effect. This is a higher-level construct bui... - [Introduction to Software Transactional Memory](https://zio.dev/reference/stm/index.md): ZIO supports Software Transactional Memory (STM) which is a modular composable concurrency data structure. It allows us to combine and compose a gr... - [STM](https://zio.dev/reference/stm/stm.md.md): An `STM[E, A]` represents an effect that can be performed transactionally resulting in a failure `E` or a success `A`. There is a more powerful var... - [TArray](https://zio.dev/reference/stm/tarray.md): `TArray` is an array of mutable references that can participate in transactions in STM. - [THub](https://zio.dev/reference/stm/thub.md): A `THub` is a transactional message hub. Publishers can publish messages to the hub and subscribers can subscribe to take messages from the hub. - [TMap](https://zio.dev/reference/stm/tmap.md): A `TMap[A]` is a mutable map that can participate in transactions in STM. - [TPriorityQueue](https://zio.dev/reference/stm/tpriorityqueue.md): A `TPriorityQueue[A]` is a mutable queue that can participate in STM transactions. A `TPriorityQueue` contains values of type `A` for which an `Ord... - [TPromise](https://zio.dev/reference/stm/tpromise.md): `TPromise` is a mutable reference that can be set exactly once and can participate in transactions in STM. - [TQueue](https://zio.dev/reference/stm/tqueue.md): A `TQueue[A]` is a mutable queue that can participate in transactions in STM. - [TRandom](https://zio.dev/reference/stm/trandom.md): `TRandom` is a random service like [Random](../services/random.md) that provides utilities to generate random numbers, but they can participate in ... - [TReentrantLock](https://zio.dev/reference/stm/treentrantlock.md): A `TReentrantLock` allows safe concurrent access to some mutable state efficiently, allowing multiple fibers to read the - [TRef](https://zio.dev/reference/stm/tref.md): A `TRef[A]` is a mutable reference to an immutable value, which can participate in transactions in STM. The mutable reference can be retrieved and ... - [TSemaphore](https://zio.dev/reference/stm/tsemaphore.md): `TSemaphore` is a semaphore with transactional semantics that can be used to control access to a common resource. It - [TSet](https://zio.dev/reference/stm/tset.md): A `TSet[A]` is a mutable set that can participate in transactions in STM. - [Chunk](https://zio.dev/reference/stream/chunk.md): A `Chunk[A]` represents a chunk of values of type `A`. Chunks are usually backed by arrays, but expose a purely functional, safe interface to the u... - [Introduction to ZIO Streams](https://zio.dev/reference/stream/index.md): The primary goal of a streaming library is to introduce **a high-level API that abstracts the mechanism of reading and writing operations using dat... - [Installing ZIO Streams](https://zio.dev/reference/stream/installation.md): In order to use ZIO Streaming, we need to add the required configuration in our SBT settings: - [SubscriptionRef](https://zio.dev/reference/stream/subscription-ref.md): A `SubscriptionRef[A]` is a `Ref` that lets us subscribe to receive the current value along with all changes to that value. - [Channel Interruption](https://zio.dev/reference/stream/zchannel/channel-interruption.md): We can interrupt a channel using the `ZChannel.interruptWhen` operator. It takes a ZIO effect that will be evaluated, if it finishes before the cha... - [Channel Operations](https://zio.dev/reference/stream/zchannel/channel-operations.md): The values from the output port of the first channel are passed to the input port of the second channel when we pipe a channel to another channel: - [Composing Channels](https://zio.dev/reference/stream/zchannel/composing-channels.md): We can write more complex channels by using `read` operators and composing them recursively. - [Creating Channels](https://zio.dev/reference/stream/zchannel/creating-channels.md): `ZChannel` have several constructors and also built-in channels, where suitable to create more complex channels. - [Introduction To ZChannels](https://zio.dev/reference/stream/zchannel/index.md): Channels are the nexus of communications, which support both reading and writing. They allow us to have a unidirectional flow of data from the inpu... - [Running a Channel](https://zio.dev/reference/stream/zchannel/running-a-channel.md): To run a channel, we can use the `ZChannel.runXYZ` methods: - [ZPipeline](https://zio.dev/reference/stream/zpipeline.md): A `ZPipeline[-Env, +Err, -In, +Out]` is a stream transformer. Pipelines accept a stream as input and return the transformed stream as output. - [Parallel Operators](https://zio.dev/reference/stream/zsink/parallel-operators.md): Like `ZStream`, two `ZSink` can be zipped together. Both of them will be run in parallel, and their results will be combined in a tuple: - [Creating Sinks](https://zio.dev/reference/stream/zsink/creating-sinks.md): The `zio.stream` provides numerous kinds of sinks to use. - [Introduction to ZSink](https://zio.dev/reference/stream/zsink/index.md): A `ZSink[R, E, I, L, Z]` is used to consume elements produced by a `ZStream`. You can think of a sink as a function that will consume a variable am... - [Leftovers](https://zio.dev/reference/stream/zsink/leftovers.md): A sink consumes a variable amount of `I` elements (zero or more) from the upstream. If the upstream is finite, we can collect leftover values by ca... - [Sink Operations](https://zio.dev/reference/stream/zsink/operations.md): Having created the sink, we can transform it with provided operations. - [Consuming Streams](https://zio.dev/reference/stream/zstream/consuming-streams.md): ```scala - [Creating ZIO Streams](https://zio.dev/reference/stream/zstream/creating-zio-streams.md): There are several ways to create ZIO Stream. In this section, we are going to enumerate some of the important ways of creating `ZStream`. - [Error Handling](https://zio.dev/reference/stream/zstream/error-handling.md): If we have a stream that may fail, we might need to recover from the failure and run another stream, the `ZStream#orElse` takes another stream, so ... - [Introduction to ZStream](https://zio.dev/reference/stream/zstream/index.md): A `ZStream[R, E, O]` is a description of a program that, when evaluated, may emit zero or more values of type `O`, may fail with errors of type `E`... - [Operations](https://zio.dev/reference/stream/zstream/operations.md): Tapping is an operation of running an effect on each emission of the ZIO Stream. We can think of `ZStream#tap` as an operation that allows us to ob... - [Resourceful Streams](https://zio.dev/reference/stream/zstream/resourceful-streams.md): Most of the constructors of `ZStream` have a special variant to lift a scoped resource to a Stream (e.g. `ZStream.fromReaderScoped`). By using thes... - [Scheduling](https://zio.dev/reference/stream/zstream/scheduling.md): To schedule the output of a stream we use `ZStream#schedule` combinator. - [Streams Are Chunked by Default](https://zio.dev/reference/stream/zstream/streams-are-chunked-by-default.md): Every time we are working with streams, we are always working with chunks. There are no streams with individual elements, these streams have always... - [Type Aliases](https://zio.dev/reference/stream/zstream/type-aliases.md): The `ZStream` data type, has two type aliases: - [ConcurrentMap](https://zio.dev/reference/sync/concurrentmap.md): A `ConcurrentMap` is a wrapper over `java.util.concurrent.ConcurrentHashMap`. - [ConcurrentSet](https://zio.dev/reference/sync/concurrentset.md): A `ConcurrentSet` is a Set wrapper over `java.util.concurrent.ConcurrentHashMap`. - [CountdownLatch](https://zio.dev/reference/sync/countdownlatch.md): A synchronization aid that allows one or more fibers to wait until a set of operations being performed in other fibers completes. - [CyclicBarrier](https://zio.dev/reference/sync/cyclicbarrier.md): A synchronization aid that allows a set of fibers to all wait for each other to reach a common barrier point. - [Introduction to ZIO's Synchronization Primitives](https://zio.dev/reference/sync/index.md): When we access shared resources in a concurrent environment, we should choose a proper synchronization mechanism to avoid incorrect results and dat... - [MVar](https://zio.dev/reference/sync/mvar.md): An `MVar[A]` is a mutable location that is either empty or contains a value of type `A`. So the `MVar` acts like a _single-element buffer_. - [ReentrantLock](https://zio.dev/reference/sync/reentrantlock.md): A `ReentrantLock` is a lock which can be acquired multiple times by the same fiber. When a fiber acquires (`lock`) a reentrant lock, it will become... - [Annotating Tests](https://zio.dev/reference/test/aspects/annotating-tests.md): We can annotate the execution time of each test using the `timed` test aspect: - [Before, After, and Around Test Aspects](https://zio.dev/reference/test/aspects/before-after-around.md): 1. We can run an effect _before_, _after_, or _around_ every test: - [Conditional Aspects](https://zio.dev/reference/test/aspects/conditional.md): When we apply a conditional aspect, it will run the spec only if the specified predicate is satisfied. - [Configuring Tests](https://zio.dev/reference/test/aspects/configuring-tests.md): To run cases, there are some [default configuration settings](../services/test-config.md) which are used by test runner, such as _repeats_, _retrie... - [Debugging and Diagnostics](https://zio.dev/reference/test/aspects/debugging-and-diagnostics.md): 1. `TestAspect.debug` — When the `TestConsole` is in the debug state, the console output is rendered to the standard output in addition to being wr... - [Environment-specific Tests](https://zio.dev/reference/test/aspects/environment-specific-tests.md): To run a test on a specific operating system, we can use one of the `unix`, `mac` or `windows` test aspects or a combination of them. Additionally,... - [Execution Strategy](https://zio.dev/reference/test/aspects/execution-strategy.md): ZIO Test has two different strategies to run members of a test suite: _sequential_ and _parallel_. Accordingly, there are two test aspects for spec... - [Flaky and Non-flaky Tests](https://zio.dev/reference/test/aspects/flaky-and-non-flaky-tests.md): Whenever we deal with concurrency issues or race conditions, we should ensure that our tests pass consistently. The `nonFlaky` is a test aspect to ... - [Ignoring Tests](https://zio.dev/reference/test/aspects/ignoring-tests.md): To ignore running a test, we can use the `ignore` test aspect: - [Introduction to Test Aspects](https://zio.dev/reference/test/aspects/index.md): A `TestAspect` is an aspect that can be weaved into specs. We can think of an aspect as a polymorphic function, capable of transforming one test in... - [Non-deterministic Test Data](https://zio.dev/reference/test/aspects/non-deterministic-test-data.md): The random process of the `TestRandom` is said to be deterministic since, with the initial seed, we can generate a sequence of predictable numbers.... - [Passing Failed Tests](https://zio.dev/reference/test/aspects/passing-failed-tests.md): The `failing` aspect makes a test that failed for any reason pass. - [Repeat and Retry](https://zio.dev/reference/test/aspects/repeat-and-retry.md): There are some situations where we need to repeat a test with a specific schedule, or our tests might fail, and we need to retry them until we make... - [Restoring State of Test Services](https://zio.dev/reference/test/aspects/restoring-state-of-test-services.md): ZIO Test has some test aspects which restore the state of given restorable test services, such as `TestClock`, `TestConsole`, `TestRandom` and `Tes... - [Changing the Size of Sized Generators](https://zio.dev/reference/test/aspects/sized.md): To change the default _size_ used by [sized generators](../property-testing/built-in-generators.md#sized-generators) we can use `size` test aspect: - [Timing-out Tests](https://zio.dev/reference/test/aspects/timing-out-tests.md): The `timeout` test aspect takes a duration and times out each test. If the test case runs longer than the time specified, it is immediately cancele... - [Built-in Assertions](https://zio.dev/reference/test/assertions/built-in-assertions.md): To create `Assertion[A]` object one can use functions defined under `zio.test.Assertion`. There are already a number of useful assertions predefine... - [Classic Assertions](https://zio.dev/reference/test/assertions/classic-assertions.md): :::note - [Introduction to ZIO Test Assertions](https://zio.dev/reference/test/assertions/index.md): Assertions are used to make sure that the assumptions on computations are exactly what we expect them to be. They are _executable checks_ for a pro... - [Smart Assertions](https://zio.dev/reference/test/assertions/smart-assertions.md): The smart assertion is a simple way to assert both _ordinary values_ and _ZIO effects_. It uses the `assertTrue` function, which uses macro under t... - [zio.test.diff.Diff](https://zio.dev/reference/test/zio-test-diff.md): When asserting two things are the same it's sometimes difficult to see the difference. Luckily there is a `zio.test.Diff` type-class. The purpose t... - [Dynamic Test Generation](https://zio.dev/reference/test/dynamic-test-generation.md): Tests in ZIO are dynamic. Meaning that they are not required to be statically defined at compile time. They can be generated at runtime effectfully. - [Introduction to ZIO Test](https://zio.dev/reference/test/index.md): **ZIO Test** is a zero dependency testing library that makes it easy to test effectual programs. In **ZIO Test**, all tests are immutable values an... - [Installing ZIO Test](https://zio.dev/reference/test/installation.md): In order to use ZIO Test, we need to add the required configuration in our SBT settings: - [Integrating ZIO Test with JUnit](https://zio.dev/reference/test/junit-integration.md): Unit testing is an essential practice in software development, enabling developers to validate the correctness and reliability of their code. JUnit... - [Built-in Generators](https://zio.dev/reference/test/property-testing/built-in-generators.md): In the companion object of the `Gen` data type, there are tons of generators for various data types. - [Getting Started With Property Checking](https://zio.dev/reference/test/property-testing/getting-started.md): The fundamental idea behind property checking is to test the properties of the target function using random inputs. - [How Generators Work?](https://zio.dev/reference/test/property-testing/how-generators-work.md): A `Gen[R, A]` represents a generator of values of type `A`, which requires an environment `R`. The `Gen` data type is the base functionality for ge... - [Introduction To Property Testing](https://zio.dev/reference/test/property-testing/index.md): In property-based testing, instead of testing individual values and making assertions on the results, we rely on testing the properties of the syst... - [Operators](https://zio.dev/reference/test/property-testing/operators.md): 1. `Gen#zipWith` — Composes this generator with the specified generator to create a cartesian product of elements with the specified function: - [Shrinking](https://zio.dev/reference/test/property-testing/shrinking.md): In Property-Based Testing, we specify certain properties of a program, then we ask the testing framework to generate random test data to discover c... - [Running Tests](https://zio.dev/reference/test/running-tests.md): We can run ZIO Tests in two ways: - [TestClock](https://zio.dev/reference/test/services/clock.md): In most cases we want unit tests to be as fast as possible. Waiting for real time to pass by is a real killer for this. - [TestConsole](https://zio.dev/reference/test/services/console.md): `TestConsole` allows testing of applications that interact with the console by modeling working with standard input and output as writing and readi... - [Introduction](https://zio.dev/reference/test/services/index.md): ZIO Test has out of the box test implementations for all built-in ZIO services, such as `Console`, `Clock`, `Random` and `System` through the follo... - [Live](https://zio.dev/reference/test/services/live.md): The `Live` trait provides access to the _live_ environment from within the test environment for effects such as printing test results to the consol... - [TestRandom](https://zio.dev/reference/test/services/random.md): When working with randomness, testing might be hard because the inputs to the tested function change on every invocation. So our code behaves in an... - [Sized](https://zio.dev/reference/test/services/sized.md): The `Sized` service enables the _Sized Generators_ to access the _size_ from the ZIO Test environment: - [TestSystem](https://zio.dev/reference/test/services/system.md): `TestSystem` supports deterministic testing of effects involving system properties. - [TestConfig](https://zio.dev/reference/test/services/config.md): The `TestConfig` service provides access to default configuration settings used by ZIO Test: - [Sharing Layers Between Multiple Files](https://zio.dev/reference/test/sharing-layers-between-multiple-files.md): In the previous example, we used the `Spec#provideXYZShared` methods to share layers between multiple specs in one file. In most cases, when the nu... - [Sharing Layers within the Same File](https://zio.dev/reference/test/sharing-layers-within-the-same-file.md): The `Spec` data type has a mechanism to share layers within all tests in a suite. Instead of acquiring and releasing dependencies for each test, we... - [Spec](https://zio.dev/reference/test/spec.md): Just like the `ZIO` data type, the `Spec` requires an environment of type `R`. When we write tests, we might need to access a service through the e... - [Test Hierarchies and Organization](https://zio.dev/reference/test/test-hierarchies-and-organization.md): A `Spec[R, E]` is the backbone of ZIO Test. All specs require an environment of type `R` and may potentially fail with an error of type `E`. - [Why ZIO Test?](https://zio.dev/reference/test/why-zio-test.md): In this section, we will discuss important features of the ZIO Test which help us to test our effectual code easily. - [Writing Our First Test](https://zio.dev/reference/test/writing-our-first-test.md): Any object that implements the `ZIOSpecDefault` trait is a runnable test. So to start writing tests we need to extend `ZIOSpecDefault`, which requi... - [ZIO Guides](https://zio.dev/guides/index.md): The following guides have been written to help you get started with ZIO with minimal effort and without the need to fully understand the underlying... - [How to Interop with Cats Effect?](https://zio.dev/guides/interop/with-cats-effect.md): [`interop-cats`](https://github.com/zio/interop-cats) has instances for the [Cats](https://typelevel.org/cats/), [Cats MTL](https://github.com/type... - [How to Interop with Future?](https://zio.dev/guides/interop/with-future.md): Basic interoperability with Scala's `Future` is now provided by ZIO, and does not require a separate module. - [How to Interop with Java?](https://zio.dev/guides/interop/with-java.md): ZIO has full interoperability with foreign Java code. Let me show you how it works and then *BOOM*, tomorrow you can show off your purely functiona... - [How to Interop with JavaScript?](https://zio.dev/guides/interop/with-javascript.md): Include ZIO in your Scala.js project by adding the following to your `build.sbt`: - [How to Migrate From Akka to ZIO?](https://zio.dev/guides/migrate/from-akka.md): Here, we summarized alternative ZIO solutions for Akka Actor features. So before starting the migration, let's see an overview of corresponding fea... - [How to Migrate from Cats Effect to ZIO?](https://zio.dev/guides/migrate/from-cats-effect.md): Cats `IO[A]` can be easily replaced with ZIO's `Task[A]` (an alias for `ZIO[Any, Throwable, A]`). - [How to Migrate from Monix to ZIO?](https://zio.dev/guides/migrate/from-monix.md): Monix's `Task[A]` can be easily replaced with ZIO's `Task[A]` (an alias for `ZIO[Any, Throwable, A]`). - [ZIO 2.x Migration Guide](https://zio.dev/guides/migrate/zio-2.x-migration-guide.md): In this guide we want to introduce the migration process to ZIO 2.x. So if you have a project written in ZIO 1.x and want to migrate that to ZIO 2.... - [ZIO Quickstart: Building GraphQL Web Service](https://zio.dev/guides/quickstarts/graphql-webservice.md): This quickstart shows how to build a GraphQL web service using ZIO. It uses - [ZIO Quickstart: Hello World](https://zio.dev/guides/quickstarts/hello-world.md): This is the simplest quickstart for a ZIO application. You can download and run it very quickly. This will give you an idea of how to write similar... - [ZIO Quickstart: Building RESTful Web Service](https://zio.dev/guides/quickstarts/restful-webservice.md): This quickstart shows how to build a RESTful web service using ZIO. It uses - [Tutorial: How to Build a GraphQL Web Service](https://zio.dev/guides/tutorials/build-a-graphql-webservice.md): Having GraphQL APIs enables the clients the ability to query the exact data they need. This powerful feature makes GraphQL more flexible than RESTf... - [Tutorial: How to Build a RESTful Web Service](https://zio.dev/guides/tutorials/build-a-restful-webservice.md): ZIO provides good support for building RESTful web services. Using _Service Pattern_, we can build web services that are modular and easy to test a... - [Tutorial: How to Create a Custom Logger for a ZIO Application?](https://zio.dev/guides/tutorials/create-custom-logger-for-a-zio-application.md): As we have seen in the [previous tutorial](enable-logging-in-a-zio-application.md), ZIO has a variety of built-in logging facilities. Also, it has ... - [Tutorial: How to Debug a ZIO Application?](https://zio.dev/guides/tutorials/debug-a-zio-application.md): Writing applications using functional programming helps us to write a base code that is less error-prone and more predictable. However, we often ma... - [Tutorial: How to Deploy a ZIO Application Using Docker?](https://zio.dev/guides/tutorials/deploy-a-zio-application-using-docker.md): Docker is a tool that allows us to package, ship, and run our applications in an isolated environment called a container. Using Docker, we can simp... - [Tutorial: How to Enable Logging in a ZIO Application](https://zio.dev/guides/tutorials/enable-logging-in-a-zio-application.md): ZIO has built-in support for logging. This tutorial will show you how to enable logging for a ZIO application. - [Tutorial: How to Encode and Decode JSON Data?](https://zio.dev/guides/tutorials/encode-and-decode-json-data.md): In this article, we will cover how to encode and decode JSON data. - [Tutorial: How to Gracefully Shutdown ZIO Applications?](https://zio.dev/guides/tutorials/gracefully-shutdown-zio-application.md): Graceful shutdown is a critical aspect of building robust and reliable software applications. It ensures that an application terminates smoothly, a... - [Tutorial: How to Make a ZIO Application Configurable?](https://zio.dev/guides/tutorials/configurable-zio-application.md): One of the most common requirements for writing an application is to be able to configure it, especially when we are writing cloud-native applicati... - [Tutorial: How to Monitor a ZIO Application Using ZIO's Built-in Metric System?](https://zio.dev/guides/tutorials/monitor-a-zio-application-using-zio-built-in-metric-system.md): ZIO has a built-in metric system that allows us to monitor the performance of our application. This is very useful for debugging and tuning our app... - [Tutorial: How to Run Our First ZIO Project With VSCode?](https://zio.dev/guides/tutorials/run-our-first-zio-project-with-vscode.md): ZIO is a _type-safe_ library for building asynchronous and concurrent applications. The Scala compiler can catch a lot of errors at compile time si... - [Tutorial: How to Run Our First ZIO Project With IntelliJ IDEA?](https://zio.dev/guides/tutorials/run-our-first-zio-project-with-intellij-idea.md): IntelliJ IDEA is a popular IDE for Java developers. It is a powerful tool for developing Java applications. Fortunately, not only does it support t... - [Caliban](https://zio.dev/ecosystem/community/caliban.md): [Caliban](https://ghostdogpr.github.io/caliban/) is a purely functional library for creating GraphQL servers and clients in Scala. - [Distage](https://zio.dev/ecosystem/community/distage.md): [Distage](https://izumi.7mind.io/distage/) is a compile-time safe, transparent, and debuggable Dependency Injection framework for pure FP Scala. - [Fhir-indexer](https://zio.dev/ecosystem/community/fhir-indexer.md): [Fhir-indexer](https://github.com/royashcenazi/fhir-indexer) is a ZIO based library for fetching FHIR resources fast and easy. - [ZIO Ecosystem Community Libraries](https://zio.dev/ecosystem/community/index.md): In this section we are going to introduce some of the most important libraries that have first-class ZIO support from the community. - [LogStage](https://zio.dev/ecosystem/community/logstage.md): [LogStage](https://izumi.7mind.io/logstage/) is a zero-cost structural logging framework for Scala & Scala.js. - [MUnit ZIO](https://zio.dev/ecosystem/community/munit-zio.md): [MUnit ZIO](https://github.com/poslegm/munit-zio) is an integration library between MUnit and ZIO. - [Rezilience](https://zio.dev/ecosystem/community/rezilience.md): [Rezilience](https://github.com/svroonland/rezilience) is a ZIO-native library for making resilient distributed systems. - [Scala k8s](https://zio.dev/ecosystem/community/scala-k8s.md): [Scala k8s](https://github.com/hnaderi/scala-k8s) is a Kubernetes client, data models and typesafe manifest generation for scala, scalajs, and scal... - [Tamer](https://zio.dev/ecosystem/community/tamer.md): [Tamer](https://github.com/laserdisc-io/tamer) is a multi-functional Kafka connector for producing data based on [ZIO Kafka](https://github.com/zio... - [Tofu ZIO 2 Logging](https://zio.dev/ecosystem/community/tofu-zio2-logging.md): [Tofu](https://docs.tofu.tf/) is a functional toolkit modules providing a comprehensive set of tools adressing - [TranzactIO](https://zio.dev/ecosystem/community/tranzactio.md): [TranzactIO](https://github.com/gaelrenoux/tranzactio) is a ZIO wrapper for some Scala database access libraries, currently for [Doobie](https://gi... - [ZIO AMQP](https://zio.dev/ecosystem/community/zio-amqp.md): [ZIO AMQP](https://github.com/svroonland/zio-amqp) is a ZIO-based AMQP client for Scala. - [ZIO Apache Parquet](https://zio.dev/ecosystem/community/zio-apache-parquet.md): [ZIO Apache Parquet](https://github.com/grouzen/zio-apache-parquet) is a ZIO-powered Apache Parquet library. - [ZIO EclipseStore](https://zio.dev/ecosystem/community/zio-eclipsestore.md): [ZIO EclipseStore](https://github.com/riccardomerolla/zio-eclipsestore) is a ZIO-based library for type-safe, efficient, and boilerplate-free acces... - [ZIO gRPC](https://zio.dev/ecosystem/community/zio-grpc.md): [ZIO-gRPC](https://scalapb.github.io/zio-grpc/) lets us write purely functional gRPC servers and clients. - [ZIO K8s](https://zio.dev/ecosystem/community/zio-k8s.md): [ZIO K8S](https://github.com/coralogix/zio-k8s) is an idiomatic ZIO client for the Kubernetes API. - [ZIO Kinesis](https://zio.dev/ecosystem/community/zio-kinesis.md): [ZIO Kinesis](https://github.com/svroonland/zio-kinesis) is a ZIO-based AWS Kinesis client for Scala. - [ZIO NebulaGraph](https://zio.dev/ecosystem/community/zio-nebula.md): [zio-nebula](https://github.com/nebula-contrib/zio-nebula) is a simple wrapper around [nebula-java](https://github.com/vesoft-inc/nebula-java/) for... - [ZIO Pulsar](https://zio.dev/ecosystem/community/zio-pulsar.md): [ZIO Pulsar](https://github.com/apache/pulsar) is the _Apache Pulsar_ client for Scala with ZIO and ZIO Streams integration. - [ZIO Slick Interop](https://zio.dev/ecosystem/community/zio-slick-interop.md): [ZIO Slick Interop](https://github.com/ScalaConsultants/zio-slick-interop) is a small library, that provides interop between Slick and ZIO. - [ZIO Temporal](https://zio.dev/ecosystem/community/zio-temporal.md): [ZIO Temporal](https://zio-temporal.vhonta.dev/) is a ZIO library for Temporal, a microservice workflow orchestration platform. - [ZIO Test Akka HTTP](https://zio.dev/ecosystem/community/zio-test-akka-http.md): [ZIO Test Akka HTTP](https://github.com/senia-psm/zio-test-akka-http) is an Akka-HTTP Route TestKit for zio-test. - [ZparkIO](https://zio.dev/ecosystem/community/zparkio.md): [ZParkIO](https://github.com/leobenkel/ZparkIO) is a boilerplate framework to use _Spark_ and _ZIO_ together. - [ZIO Compatible Libraries](https://zio.dev/ecosystem/compatible.md): List of ZIO compatible libraries: - [ZIO Ecosystem](https://zio.dev/ecosystem/index.md): ZIO has a rich ecosystem of libraries and tools that enhance its capabilities and provide additional functionality. This ecosystem includes librari... - [ZIO Ecosystem Official Libraries](https://zio.dev/ecosystem/officials/index.md): Official ZIO libraries are hosted in the [ZIO organization](https://github.com/zio/) on GitHub, and are generally maintained by core contributors t... - [Project Templates](https://zio.dev/ecosystem/templates.md): List of project starters, bootstrap tools or, templates. - [ZIO Tools](https://zio.dev/ecosystem/tools.md): - [ZIO IntelliJ](https://github.com/zio/zio-intellij) — A complementary, community-developed plugin for IntelliJ IDEA, brings enhancements when usi... - [Articles](https://zio.dev/resources/articles.md): :::caution - [Summary](https://zio.dev/resources/index.md): ZIO has a huge ecosystem of libraries, tools, talks, tutorials, and more. In this section, we are going to introduce some of the most important ones. - [Projects using ZIO](https://zio.dev/resources/poweredbyzio.md): - [Rudder](https://github.com/normation/rudder) — an example about how to manage error ADT in several sub-projects and specialized sub-domains, and... - [Sample Projects](https://zio.dev/resources/sampleprojects.md): - [GitHub Release Pager with ZIO 2.0](https://github.com/psisoyev/release-pager) by [Pavels Sisojevs](https://github.com/psisoyev) - [Videos](https://zio.dev/resources/videos.md) - [ZIO Events](https://zio.dev/events/index.md): ZIO has a number of events that are organized by the community all around the world. These events are a great way to learn about ZIO, meet other ZI... - [Frequently Answered Questions (FAQ)](https://zio.dev/faq.md): In this page we are going to answer general questions related to the ZIO project. - [ZIO Adopters](https://zio.dev/adopters.md): Following is a partial list of companies happily using ZIO in production to craft concurrent applications. - [Compile Time Errors for Handling Combinators](https://zio.dev/can_fail.md): ZIO provides a variety of combinators to handle errors such as `orElse`, `catchAll`, `catchSome`, `option`, `either`, and `retry`. However, these c... - [Code of Conduct](https://zio.dev/code-of-conduct.md): We are committed to providing a friendly, safe and welcoming - [Coding Guidelines](https://zio.dev/coding-guidelines.md): These are coding guidelines strictly for ZIO contributors for ZIO projects and - [Contributing to The ZIO Documentation](https://zio.dev/contributing-to-documentation.md): The ZIO documentation is provided by a worldwide community, just like the project itself. So if you are reading this page, you can help us to impro... - [Contributing to the ZIO Ecosystem Projects](https://zio.dev/contributing-to-zio-ecosystem.md): The ZIO ecosystem is provided by a worldwide community, just like the project itself. So if you are reading this page, you can help us to improve t... - [Contributor Guidelines](https://zio.dev/contributor-guidelines.md): Thank you for your interest in contributing to ZIO, which is a small, zero-dependency library for doing type-safe, composable concurrent and asynch... - [Introduction to izumi-reflect](https://zio.dev/izumi-reflect/index.md): > @quote: Looks a bit similar to TypeTag - [ZIO AMQP](https://zio.dev/zio-amqp/index.md): ZIO AMQP is a ZIO-based wrapper around the RabbitMQ client. It provides a streaming interface to AMQP queues and helps to prevent you from shooting... - [Artifacts](https://zio.dev/zio-aws/artifacts.md): ```scala - [Aspects](https://zio.dev/zio-aws/aspects.md): It is possible to define _aspects_ of type `AwsCallAspect[R]` that can modify the behavior of the AWS client modules. This can be used for example - [Changelog](https://zio.dev/zio-aws/changelog.md): Note: this is a manually maintained list of important changes. Because of having auto-release from CI, this - [Configuration](https://zio.dev/zio-aws/configuration.md): Each _service module_ depends on the `AwsConfig` layer. This layer is responsible for setting up the - [Examples](https://zio.dev/zio-aws/examples.md): The following example uses the ElasticBeanstalk and EC2 APIs to print some info. - [Summary](https://zio.dev/zio-aws/getting-started.md): Low-level AWS wrapper for [ZIO](https://zio.dev) for _all_ AWS services using the AWS Java SDK v2. - [HTTP](https://zio.dev/zio-aws/http.md): By default the AWS Java SDK uses _netty_ under the hood to make the HTTP client calls. `zio-aws` defines the http client - [Overview](https://zio.dev/zio-aws/index.md): [ZIO AWS](https://zio.dev/zio-aws) is AWS wrapper for [ZIO](https://zio.dev) for _all_ AWS services using the AWS Java SDK v2. - [Migration guide](https://zio.dev/zio-aws/migration-guide.md): There are some major changes compared to the ZIO 1 version (v3.x.x.x and v4.x.x.x). This section contains detailed information about what changed a... - [Wrappers](https://zio.dev/zio-aws/wrappers.md): The live implementation depends on a core _AWS configuration layer_: - [Compile-Time Resource Safety with Scope](https://zio.dev/zio-blocks/guides/compile-time-resource-safety-with-scope.md): Welcome to ZIO Blocks Scope—a library that makes resource management safe, composable, and verifiable at compile time. If you've ever struggled wit... - [Query DSL with Reified Optics — Part 3: Extending the Expression Language](https://zio.dev/zio-blocks/guides/query-dsl-extending.md): In this guide, we will extend the ZIO Blocks query DSL with an expression language that goes beyond what `SchemaExpr` provides out of the box. By t... - [Query DSL with Reified Optics — Part 4: A Fluent SQL Builder](https://zio.dev/zio-blocks/guides/query-dsl-fluent-builder.md): In this guide, we will build a fluent, type-safe SQL statement builder on top of the query expression language from Parts 1–3. By the end, you will... - [Query DSL with Reified Optics — Part 1: Expressions](https://zio.dev/zio-blocks/guides/query-dsl-reified-optics.md): In this guide, we will build a type-safe query DSL for filtering, comparing, and computing over domain data using ZIO Blocks' reified optics and sc... - [Query DSL with Reified Optics — Part 2: SQL Generation](https://zio.dev/zio-blocks/guides/query-dsl-sql.md): In this guide, we will build a SQL query generator that translates ZIO Blocks' `SchemaExpr` expression trees into SQL WHERE clauses, SELECT stateme... - [Migrating from ZIO Schema to ZIO Blocks Schema](https://zio.dev/zio-blocks/guides/zio-schema-migration.md): This guide helps you migrate an application that uses [ZIO Schema](https://github.com/zio/zio-schema) (version 1.x) to [ZIO Blocks Schema](https://... - [ZIO Blocks](https://zio.dev/zio-blocks/index.md): **Modular, zero-dependency building blocks for modern Scala applications.** - [Path Interpolator](https://zio.dev/zio-blocks/path-interpolator.md): The path interpolator `p"..."` is a compile-time string interpolator for constructing `DynamicOptic` instances in ZIO Blocks. It provides a clean, ... - [Allows](https://zio.dev/zio-blocks/reference/allows.md): `Allows[A, S]` is a compile-time capability token that proves, at the call site, that type `A` satisfies the structural grammar `S`. A capability t... - [BindingResolver](https://zio.dev/zio-blocks/reference/binding-resolver.md): `BindingResolver` is the **read-only interface for looking up bindings by type identity** during schema rebinding. Given a type `A`, a resolver sea... - [The Binding Data Type](https://zio.dev/zio-blocks/reference/binding.md): `Binding` is a sealed trait in ZIO Blocks that provides the operational machinery for constructing and deconstructing values of schema-described ty... - [Chunk](https://zio.dev/zio-blocks/reference/chunk.md): `Chunk[A]` is an immutable, indexed sequence optimized for high-performance operations. Unlike Scala's built-in collections, Chunk is designed for ... - [Codec](https://zio.dev/zio-blocks/reference/codec.md): `Codec[DecodeInput, EncodeOutput, Value]` is the base abstraction for encoding and decoding values between a specific input representation and a sp... - [Combinators](https://zio.dev/zio-blocks/reference/combinators.md): The `combinators` module provides compile-time typeclasses for composing and decomposing values in type-safe ways. Each module focuses on a specifi... - [Context](https://zio.dev/zio-blocks/reference/context.md): `Context[+R]` is a type-indexed heterogeneous collection that stores values of different types, indexed by their types, with compile-time type safe... - [Docs Reference](https://zio.dev/zio-blocks/reference/docs.md): Complete API reference for the zio-blocks-docs module - a zero-dependency GitHub Flavored Markdown library. - [DynamicOptic](https://zio.dev/zio-blocks/reference/dynamic-optic.md): `DynamicOptic` is a runtime path through nested data structures in ZIO Blocks. It is the untyped, - [DynamicSchema](https://zio.dev/zio-blocks/reference/dynamic-schema.md): `DynamicSchema` is a **type-erased schema container** that wraps a `Reflect.Unbound[_]` tree — all the structural information from a `Schema[A]` (f... - [DynamicValue](https://zio.dev/zio-blocks/reference/dynamic-value.md): `DynamicValue` is a schema-less, dynamically-typed representation of any structured value in ZIO Blocks. It provides a universal data model that ca... - [Serialization Formats](https://zio.dev/zio-blocks/reference/formats.md): ZIO Blocks Schema provides automatic codec derivation for multiple serialization formats. Once you have a `Schema[A]` for your data type, you can d... - [HTTP Model](https://zio.dev/zio-blocks/reference/http-model.md): `zio-http-model` is a **pure, zero-dependency HTTP data model** for building HTTP clients and servers. It provides immutable types representing req... - [JsonDiffer](https://zio.dev/zio-blocks/reference/json-differ.md): `JsonDiffer` is a **diff algorithm for JSON values** that computes the minimal [`JsonPatch`](./json-patch.md) transforming one `Json` value into an... - [JsonPatch](https://zio.dev/zio-blocks/reference/json-patch.md): `JsonPatch` is an **untyped, composable patch** for [`Json`](./json.md) values. It represents a sequence of operations that transform one `Json` va... - [JSON Schema](https://zio.dev/zio-blocks/reference/json-schema.md): `JsonSchema` provides first-class support for [JSON Schema 2020-12](https://json-schema.org/specification-links.html#2020-12) in ZIO Blocks. It ena... - [Json](https://zio.dev/zio-blocks/reference/json.md): `Json` is an algebraic data type (ADT) for representing JSON values in ZIO Blocks. It provides a type-safe, schema-free way to work with JSON data,... - [Lazy](https://zio.dev/zio-blocks/reference/lazy.md): The `Lazy[A]` data type represents a deferred computation that produces a value of type `A`. Unlike Scala's built-in `lazy val`, ZIO Blocks' `Lazy`... - [MediaType](https://zio.dev/zio-blocks/reference/media-type.md): `MediaType` is a **type-safe representation of IANA media types** (also known as MIME types). It captures structured metadata about content types i... - [Modifier](https://zio.dev/zio-blocks/reference/modifier.md): `Modifier` is a sealed trait that provides a mechanism to attach metadata and configuration to schema elements. Modifiers serve as annotations for ... - [Optics](https://zio.dev/zio-blocks/reference/optics.md): Optics are a fundamental feature of ZIO Blocks that enable type-safe, composable access and modification of nested data structures. What sets ZIO B... - [Patching](https://zio.dev/zio-blocks/reference/patch.md): The Patching system in ZIO Blocks provides a type-safe, serializable way to describe and apply transformations to data structures. Unlike direct mu... - [Reflect](https://zio.dev/zio-blocks/reference/reflect.md): The `Reflect` data type is the foundational data structure underlying ZIO Blocks. While `Schema[A]` is the user-facing API that wraps a `Reflect`, ... - [Register System](https://zio.dev/zio-blocks/reference/registers.md): The register system is one of the key innovations in ZIO Blocks (ZIO Schema 2) that enables **zero-allocation, box-free construction and deconstruc... - [DeferHandle](https://zio.dev/zio-blocks/reference/resource-management/defer-handle.md): `DeferHandle` is a handle returned by `Scope.defer` that allows cancelling a registered finalizer before the scope closes: - [Finalization](https://zio.dev/zio-blocks/reference/resource-management/finalization.md): `Finalization` is the result of running all finalizers in a scope, collecting any errors that occurred during cleanup: - [Finalizer](https://zio.dev/zio-blocks/reference/resource-management/finalizer.md): `Finalizer` is a minimal capability interface for registering cleanup actions. It exposes only the `Finalizer#defer` method, preventing code from a... - [Resource Management & Dependency Injection](https://zio.dev/zio-blocks/reference/resource-management/index.md): Resource management and dependency injection are fundamental to building reliable, maintainable applications. ZIO Blocks provides three complementa... - [Resource](https://zio.dev/zio-blocks/reference/resource-management/resource.md): `Resource[A]` is a **lazy recipe for managing resource lifecycles**, encapsulating both acquisition and finalization tied to a `Scope`. Resources d... - [Scope](https://zio.dev/zio-blocks/reference/resource-management/scope.md): `Scope` is a **compile-time safe resource lifecycle manager** that tags allocated values with a scope-specific type, preventing use-after-close at ... - [Unscoped](https://zio.dev/zio-blocks/reference/resource-management/unscoped.md): `Unscoped[A]` is a marker typeclass for types that can safely escape a scope without tracking. Types with an `Unscoped` instance are considered "sa... - [Wire](https://zio.dev/zio-blocks/reference/resource-management/wire.md): `Wire[-In, +Out]` is a **compile-time safe recipe for constructing a service and its dependencies**. Wires describe how to construct an `Out` value... - [SchemaError](https://zio.dev/zio-blocks/reference/schema-error.md): `SchemaError` is a **structured error type** for schema operations in ZIO Blocks. It represents one or more validation, conversion, or structural f... - [As](https://zio.dev/zio-blocks/reference/schema-evolution/as.md): `As[A, B]` is a **bidirectional conversion type class** that extends `Into[A, B]` with a reverse direction. In addition to converting `A → B` via `... - [Schema Evolution](https://zio.dev/zio-blocks/reference/schema-evolution/index.md): Schema evolution is the process of changing data structures over time while keeping existing data readable and systems interoperable. ZIO Blocks pr... - [Into](https://zio.dev/zio-blocks/reference/schema-evolution/into.md): `Into[-A, +B]` is a **one-way conversion type class** that converts values of type `A` into values of type `B`, returning `Either[SchemaError, B]` ... - [SchemaExpr](https://zio.dev/zio-blocks/reference/schema-expr.md): `SchemaExpr[A, +B]` is a **schema-aware expression** that computes a result of type `B` from an input value of type `A`. The input type `A` must be... - [Schema](https://zio.dev/zio-blocks/reference/schema.md): `Schema[A]` is the primary data type in ZIO Blocks (ZIO Schema 2) that contains reified information about the structure of a Scala data type `A`, t... - [Streams](https://zio.dev/zio-blocks/reference/streams.md): `zio.blocks.streams` is a **synchronous, pull-based** streaming library for **Scala 3** (and Scala 2.13) with typed errors, resource safety, and pr... - [Structural Types](https://zio.dev/zio-blocks/reference/structural-types.md):