Skip to content
CAI
Software that uses CAICheck a score

zio/zio-prelude

68.8

Adequate · 20 September 2026

31k

lines of production code

Scala

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is the ZIO Prelude, a functional programming library that provides a comprehensive set of type classes, algebraic data types, and recursion schemes for the ZIO ecosystem. It enables developers to model complex behaviors through abstractions like Newtypes with compile-time validation, ZPure for stateful computations, and coherent derivation for equality and debugging. The library supports cross-platform compilation across JVM, JavaScript, and Native, ensuring consistent algebraic laws and performance across different environments.

How it got here

2020 — ZIO 2 migration and infrastructure overhaul

13 changes.

The project underwent a comprehensive migration to ZIO 2, restructuring the ZIO Prelude with new type classes, data types, and multi-platform support. This period also featured a major overhaul of the build and CI infrastructure, including upgrades to Scala, sbt, and the transition to GitHub Actions, alongside the removal of legacy code and documentation sites.

2021 — Algebraic structures and Scala 3 support

20 changes.

This period focused on expanding the ZIO Prelude with foundational category theory primitives, recursion schemes, and a comprehensive suite of newtype wrappers for algebraic and logical operations. Significant effort was dedicated to implementing version-specific features for Scala 3, including macro-based equality derivation and compile-time validation, while maintaining parallel support for Scala 2. The work was underpinned by extensive property-based testing and law verification to ensure the correctness of these new algebraic structures and type class instances.

2022–2024 — Scala 2.12 compatibility and Magnolia integration

8 changes.

This period focused on extending Scala 2.12 compatibility by resolving cyclic alias errors in Newtype and Subtype abstractions and implementing compatibility layers for IterableOnce and ForEach. It also introduced automatic Debug instance derivation via Magnolia and optimized the ZPure execution engine's internal stack implementation.

Features

Add Prelude type-class instances for Scala parallel collections

The \scala-parallel-collections\ module now provides \zio.prelude\ type-class instances (such as \Equal\, \Hash\, \Ord\, \PartialOrd\, \Invariant\, \ForEach\, and \AssociativeFlatten\) for Scala's immutable parallel collections (\ParMap\, \ParSeq\, and \ParSet\). This enables users to apply prelude laws and operations directly to parallel collections, with specific implementations handling the constraints of parallel data structures (e.g., using object equality for keys in \ParMap\).

scala-parallel-collections/src/main · high confidence

Added ConsoleUtils for styled console output

A new ConsoleUtils object has been added to the macros/shared module, providing helper methods to wrap strings with ANSI escape codes for console styling (e.g., underlined, green, yellow, red, blue, magenta, cyan, dim, bold). This enables consistent colored and formatted text output in console-based interactions within the ZIO Prelude macros.

macros/shared/src/main/scala · high confidence

Added Folder and Unfolder types for recursion schemes

The ZIO Prelude now includes Folder and Unfolder types in the recursive package to support recursion schemes. Folder acts as a catamorphism (folding a structure into a value) and Unfolder acts as an anamorphism (unfolding a value into a structure), both providing invariant type class instances and zip operations for combining transformations.

core/shared/src/main/scala/zio/prelude/recursive · high confidence

Added Scala 2 examples for SmartTypes and custom assertions

The examples directory now includes Scala 2-specific demonstrations for SmartTypes (Subtype and Newtype) and custom assertions. Users can see how to define typed wrappers like Natural, Age, and Email with built-in validation rules, as well as how to implement custom assertions for Newtypes using assertCustom.

examples/shared/src/main/scala-2 · high confidence

Added Scala 3 examples for Smart Types and Validators

New example files have been added to the Scala 3 source directory to demonstrate the library's Smart Types and Validation capabilities. The SmartTypes example shows how to define custom subtypes (like Natural and Age) and newtypes (like MyRegex and Email) using inline assertions, including complex regex patterns and custom validation logic. The validators example provides a standalone validator object for checking palindrome strings, illustrating how to implement custom validation rules.

examples/shared/src/main/scala-3 · high confidence

Automatic derivation of Debug instances via Magnolia

Users can now automatically derive the \Debug\ typeclass for case classes, value classes, objects, and sealed traits in both Scala 2 and Scala 3. This change introduces Magnolia-based derivation logic (\DeriveDebug\) that recursively generates debug representations for complex types, eliminating the need for manual \Debug\ implementations.

magnolia/shared · high confidence

Experimental category theory primitives and algebraic structures

The \experimental\ package now includes a foundational set of category theory and algebraic abstractions, providing new type classes such as \Absorption\, \DistributiveProd\, \Annihilation\, \Complement\, \Divide\, \Subtract\, and \PartialDivide\ for numeric and collection types. It also introduces categorical composition traits like \ApplicationCompose\, \BothCompose\, and \EitherCompose\ with corresponding syntax for currying, uncurrying, and parallel composition. These additions are accompanied by coherence helpers in the \coherent\ sub-package to ensure consistent equality checks across these algebraic structures.

experimental/shared · high confidence

Introduction of ZIO Prelude core types and ZPure effect system

This release introduces the foundational types and effect system for ZIO Prelude. It adds \ZPure\, a purely functional effect type that models computations with state, environment, logging, and failure, along with a comprehensive benchmark suite (\ZPureFullBenchmark\) to measure its performance. The library also provides core algebraic data types including \These\ (for representing Left, Right, or Both values), \ZValidation\ (for accumulating errors and logs), \NonEmptyList\, \ParSeq\ (for modeling parallel and sequential events), \Optional\ (a custom option type with implicit conversions), and \Debug\ (for structured, renderable debugging representations). Additionally, it brings in typeclass hierarchies like \Ord\, \Divariant\, and \Equal\ to support ordering, variance, and equality checks across these new types.

repository · high confidence

Introduction of newtype wrappers for arithmetic and logical operations

The \zio.prelude.newtypes\ package now provides a suite of newtype wrappers to model specific algebraic structures and logical operations. This includes \Sum\ and \Prod\ for addition and multiplication, \Or\ and \And\ for logical disjunction and conjunction, and parameterized variants \OrF\ and \AndF\. Additionally, it introduces \First\, \Last\, \Min\, and \Max\ for selecting elements, as well as \Failure\, \FailureIn\, and \FailureOut\ for error state modeling. A \Natural\ newtype is also added, enforcing non-negative integers with specific arithmetic behaviors for addition, multiplication, and subtraction.

core/shared/src/main/scala-2/zio/prelude/newtypes · high confidence

New coherent derivation instances for ZIO Prelude type classes

The \zio.prelude.coherent\ package now provides a comprehensive set of automatic derivation instances that combine ZIO Prelude type classes (such as \Covariant\, \AssociativeBoth\, \CommutativeIdentity\, and \IdentityFlatten\) with \DeriveEqual\. This allows users to automatically derive \Equal\ instances for complex algebraic structures without manual implementation. Additionally, the \CovariantIdentityBoth\ trait introduces optimized \collectM\ and \forEach\ methods for collections, improving how effects are collected and transformed.

core/shared/src/main/scala/zio/prelude/coherent · high confidence

New experimental lattice and ring law definitions

The \experimental-laws/shared\ module now includes formal law definitions for several algebraic structures, enabling users to verify instances of these structures. Specifically, this change adds \AbsorptionLaws\ (join and meet absorption), \AnnihilationLaws\ (left and right annihilation), \DistributiveAbsorptionLaws\ (join and meet distributive absorption), \DistributiveProdLaws\ (left and right distributivity), \ExcludedMiddleLaws\, \InvolutionLaws\, and \NoncontradictionLaws\. These laws provide the testing infrastructure for \AbsorptionEqual\, \AnnihilationEqual\, \DistributiveAbsorptionEqual\, \DistributiveProdEqual\, \ExcludedMiddleEqual\, \InvolutionEqual\, and \NoncontradictionEqual\ type classes within the ZIO Prelude experimental package.

experimental-laws/shared · high confidence

New property-based testing laws and generators for ZIO Prelude

The \laws/shared\ module now includes a comprehensive suite of property-based tests and generators for ZIO Prelude type classes. This adds formal law definitions for \Equal\, \Hash\, \Ord\, \PartialOrd\, \Associative\, \Commutative\, \Identity\, \Inverse\, \Idempotent\, \Covariant\, \Contravariant\, \IdentityBoth\, \IdentityEither\, \IdentityFlatten\, \AssociativeBoth\, \AssociativeEither\, \AssociativeFlatten\, \CommutativeBoth\, \CommutativeEither\, \ForEach\, and \NonEmptyForEach\. It also introduces \GenFs\ and \Gens\ to provide higher-kinded and specific data type generators (such as \Cause\, \Exit\, \Future\, \Map\, \NonEmptyChunk\, \ParSeq\, \These\, \Try\, and \Validation\) required to run these property tests.

laws/shared · high confidence

Scala 3 newtype definitions for algebraic structures and error handling

The library now provides Scala 3-specific definitions for various newtypes in the \zio.prelude.newtypes\ package. This includes algebraic structures such as \Sum\ (addition), \Prod\ (multiplication), \Or\ (logical disjunction), \And\ (logical conjunction), and parameterized variants like \AndF\, \OrF\, \AndThen\, \Both\, \First\, \Last\, \Min\, and \Max\. Additionally, newtypes for error handling (\Failure\, \FailureIn\, \FailureOut\) and a \Natural\ number type with arithmetic operations (\plus\, \minus\, \times\) and assertions are introduced to support Scala 3 compilation.

core/shared/src/main/scala-3/zio/prelude/newtypes · high confidence

ZIO Prelude restructured with new type classes and ZIO 2 integration

The ZIO Prelude library has been significantly restructured and upgraded to align with ZIO 2. This change introduces a comprehensive set of new type classes to the core abstraction hierarchy, including Associative, AssociativeBoth, AssociativeCompose, AssociativeEither, AssociativeFlatten, Bicovariant, Commutative, CommutativeBoth, CommutativeEither, and Contravariant. It also adds new data types and utilities such as AnyType, Const, and Optional. The implementation integrates deeply with ZIO 2 types, providing instances for ZIO, ZLayer, ZStream, and ZSTM, and introduces syntax for composition (andThen/compose) and parallel combination (both/either).

core/shared/src/main/scala/zio/prelude · high confidence

Removals

Removal of legacy Debug, Equal, and HelloWorld components

The legacy \Debug\ and \Equal\ typeclasses, along with their associated syntax extensions (\DebugSyntax\, \EqualSyntax\) and the \HelloWorld\ example application, have been removed from the \zio.prelude\ package. This cleanup eliminates the old encoding of these core abstractions and the experimental JSON codec demo, streamlining the prelude by discarding these specific implementation artifacts.

src/main · high confidence

Removal of legacy Docusaurus 1 website configuration

The legacy Docusaurus 1 website files have been removed from the repository. This includes the deletion of the main homepage component (\website/pages/en/index.js\), the sidebar navigation configuration (\website/sidebars.json\), and the site configuration file (\website/siteConfig.js\). These changes eliminate the previous static site structure that defined the project's overview, use cases, and API documentation layout.

website · high confidence

Behavioural changes

Major build and CI infrastructure overhaul

The project has significantly upgraded its development tooling and continuous integration setup. The Node.js runtime was updated from v10 to v20.9.0, and the sbt launcher was upgraded from v0.13.18 to v1.7.1, which also updated the default Scala versions (2.13 to 2.13.9, 2.12 to 2.12.16). Scalafmt was upgraded from v2.3.2 to v3.10.6, requiring configuration adjustments for dialects and docstrings. The CI system was migrated from CircleCI to GitHub Actions, and automated dependency updates are now managed via Mergify, which automatically squashes and merges Scala Steward pull requests. Additionally, the README is now auto-generated by the zio-sbt-website plugin.

(repo-wide) · high confidence

Newtype and Subtype type aliases resolved for Scala 2.12+ compatibility

To resolve cyclic alias errors in Scala 2.12+, the library introduces version-specific implementations for the Newtype and Subtype abstractions. New files \NewtypeVersionSpecific.scala\ and \Subtype.scala\ define the \Newtype\ type alias and the \Subtype\ abstract class specifically for the Scala 2.12+ source directory, ensuring that the type system constraints (such as \Subtype\ extending \Newtype\ with a refined \Type\) compile correctly without circularity issues on these Scala versions.

core/shared/src/main/scala-2.12+ · high confidence

Optimized internal stack implementation for ZPure

The ZPure execution engine now uses a new, lightweight internal Stack implementation to improve performance. This change introduces a specialized data structure optimized for the specific usage patterns of ZPure, replacing previous mechanisms with a more efficient array-based approach that reduces overhead during pure computations.

core/shared/src/main/scala/zio/prelude/fx · high confidence

The custom \Footer.js\ component, which previously rendered the site's footer with links to GitHub, Discord, and Scaladoc, has been deleted from the website core. This change removes the custom footer implementation, likely shifting the site to a default footer provided by the underlying documentation framework.

website/core · high confidence

Removed website static assets and custom CSS

The website's static assets have been cleaned up by deleting the custom CSS file (\website/static/css/custom.css\) and several SVG illustration files (\undraw\_code\_review.svg\, \undraw\_online.svg\, \undraw\_open\_source.svg\, and \undraw\_operating\_system.svg\). This removes the custom styling rules and the specific vector images that were previously served from the static directory.

website/static · high confidence

Scala 2-specific Newtype and version-specific trait implementations

This change introduces Scala 2-specific implementations for the Newtype system and related version-specific traits. It adds \DebugVersionSpecific\ and \EqualVersionSpecific\ traits for Scala 2, and provides a dedicated \Newtype.scala\ implementation for Scala 2 that includes support for Smart Newtypes with compile-time assertions, subtype creation, and class tag handling. This ensures that Newtype functionality, including validation and type class derivation, works correctly on Scala 2, complementing the existing Scala 3 implementation.

core/shared/src/main/scala-2/zio/prelude · high confidence

Scala 2.12 compatibility layer for IterableOnce and ForEach

Added Scala 2.12-specific source files to provide compatibility for \IterableOnce\ and \ForEach\ operations. The new \IterableOnceCompat\ trait supplies \iterator\ and \knownSize\ methods to mimic Scala 2.13's \IterableOnce\ interface, while \InvariantVersionSpecific\ introduces an implicit \ForEach\ derivation for \Iterable\ types using \CanBuildFrom\, enabling collection-based effects to work correctly on Scala 2.12.

core/shared/src/main/scala-2.12 · high confidence

Scala 2.13+ specific ForEach derivation and IterableOnce compatibility

Added Scala 2.13+ specific implementation files to support the \ForEach\ type class for \Iterable\ types and provide a compatibility shim for \IterableOnce\. The new \InvariantVersionSpecific\ trait derives \ForEach\ from \Iterable\ using \BuildFrom\, enabling collection operations within the prelude for Scala 2.13+ users, while \IterableOnceCompat\ ensures compatibility with the \IterableOnce\ trait introduced in Scala 2.13.

core/shared/src/main/scala-2.13+ · high confidence

Scala 3-specific prelude implementations for debugging, equality derivation, and newtypes

This change introduces a set of Scala 3 version-specific files in the \zio.prelude\ package to leverage Scala 3 features. It adds \DebugVersionSpecific\ to provide \Debug\ instances for \IArray\, \EqualVersionSpecific\ to automatically derive \Equal\ instances for product and sum types using Scala 3's \Mirror\, and \Liftables\/\Macros\ to enable compile-time validation of assertions and improved error messages for newtypes. Additionally, it defines \Newtype.scala\ and \Validator.scala\ to support custom newtype validation with compile-time checks and class tag support, replacing or augmenting previous Scala 2/3 shared implementations with Scala 3-native code.

core/shared/src/main/scala-3/zio/prelude · high confidence

Support for new string and regex assertion operators in Scala 2 macros

The Scala 2 macro implementation in \Liftables.scala\ has been updated to support new assertion capabilities, specifically \startsWithIgnoreCase\ and \endsWithIgnoreCase\ for strings, as well as various regex operators. This change enables the macro to correctly lift and unlift these new assertion types during compile-time code generation, allowing users to utilize these enhanced pattern-matching and string-checking features in their Scala 2 projects.

macros/shared/src/main/scala-2 · high confidence

Fixes

Fixes cyclic alias error in newtype examples

Resolves a compilation error caused by cyclic aliases when nesting newtypes. The example code now correctly defines a \GenericItemId\ newtype based on \UUID\ and a \SpecificItemId\ subtype, ensuring that the \GreatTypeclass\ implicit resolution works without hitting Scala 2's cyclic reference restrictions.

examples/shared/src/main/scala-2.12+ · high confidence

Test coverage

Added JMH benchmarks for ZIO Prelude collection and state operations; Added Scala 2.12/2.13-specific test types for custom Newtype assertions; Added Scala 3 tests for derivation and newtype validation; Added comprehensive test suite for ZIO Prelude typeclass laws and utilities; Added comprehensive test suite for ZPure; Added experimental prelude law tests; Added law-based tests for Scala parallel collections; Added test fixtures for newtype case-insensitive assertions; Added test for FutureCommutativeEither behavior; Added tests for Magnolia-based Debug derivation; Added tests for Optional as IterableOnce; Removed HelloWorldSpec test suite.

Dependencies

Major build system and dependency upgrades

The build infrastructure has been significantly upgraded: sbt is updated from 1.3.7 to 1.13.0, Scala versions are raised to 2.12.21, 2.13.16, and 3.3.8, and Scala Native is upgraded to 0.5.12. Several sbt plugins have been updated or replaced, including sbt-scalafix (0.14.9), sbt-buildinfo (0.13.2), sbt-mdoc (2.9.2), and sbt-scalajs (1.20.1), while sbt-bloop has been removed. The build configuration also introduces new compiler options for Scala 3, enables fatal warnings in CI, and adds support for ZIO 2 via the ZIO 2 merge commit.

project · high confidence

Upgrade ZIO to 2.1.23 and migrate build to multi-platform support

The project updates its core dependency, ZIO, from version 1.0.0-RC17 to 2.1.23, bringing the library up to date with the latest stable ZIO 2.x features. Alongside this dependency upgrade, the build configuration has been significantly restructured to support cross-compilation across JVM, JavaScript, and Native platforms, replacing the previous single-platform setup with dedicated project definitions for each target. Additionally, the documentation site infrastructure has been updated by removing the legacy Docusaurus 1 website package and introducing new, minimal package.json files for the docs and website directories.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 69.

Lenses

  • Code Health 91
  • Architecture 99
  • Maturity 65
  • Readiness 83
  • Security 60

Changes since last survey

  • 300 commits — 291 feature/other, 9 fixes

By area

  • project/plugins.sbt — 85 commits
  • (root) — 74 commits
  • .github/workflows — 51 commits
  • project/build.properties — 28 commits
  • core/shared — 24 commits
  • project/BuildHelper.scala — 22 commits
  • core-tests/shared — 6 commits
  • website/docs — 5 commits
  • docs/functional-abstractions — 2 commits
  • docs/zpure — 1 commit
  • experimental/shared — 1 commit
  • magnolia-tests/shared — 1 commit

Notable commits

  • fix: Fix ZPure zipPar operators (#1431)
  • fix: Fix diagrams (#1618)
  • fix: Fix docs website build in CI (#1676)
  • fix: Fix scala steward CI (#1434)
  • fix: Fix: SubtypeCustom[A] should behave like subtype of A (#1328)
  • fix: Fixed #1312 - NonEmptySet#removeNonEmpty (#1313)
  • fix: Refresh Mergify config: fix invalid team assignee (#1684)
  • fix: fixes #1180: Type-class instances for zio.Config (#1406)
  • fix: fixes #1399: add fold and syntax. (#1408)
  • change: ./sbt (#1472)
  • change: Add FMap as a primitive to ZPure (#1607)
  • change: Add Syntax for groupByNonEmpty and groupByNonEmptyM (#1554)
  • change: Add ZValidation.validateAll_ (#1580)
  • change: Add all the typeclasses instance for the zio.prelude.data.Optional type (copied from the Option instances) (#1415)
  • change: Avoid tuple allocation in ZValidation#zipWithPar (#1630)
  • change: Bring Ring-like structures to ZIO Prelude (#351)
  • change: Bump actions/checkout from 4.1.2 to 4.1.3 (#1297)
  • change: Bump actions/checkout from 4.1.3 to 4.1.4 (#1302)
  • change: Bump actions/checkout from 4.1.4 to 4.1.5 (#1318)
  • change: Bump actions/checkout from 4.1.5 to 4.1.6 (#1320)
  • …and 280 more

Architecture

  • 0 containers · 1 bounded contexts · 0 dependency edges (baseline)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

zio/zio-prelude was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 1ae2438d67177eba8bd3eb0685e2a3ccbe5875f9 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.