Data Types
Introduction
The blocks in this group are small, general-purpose building blocks. Two of them offer alternatives to everyday standard-library types that allocate less, and the third checks the composition of tuples, eithers and unions at compile time.
The Blocks
The group has three blocks.
| Block | Artifact | What It Is For |
|---|---|---|
| Chunk | zio-blocks-chunk | High-performance immutable indexed sequences with zero-boxing builders |
| Maybe | zio-blocks-maybe | Optional values that store a present reference as is, without a wrapper object (Scala 3) |
| Combinators | zio-blocks-combinators | Compile-time composition and decomposition of tuples, eithers, and unions |
How the Blocks Differ
Chunk is an immutable, indexed sequence with a functional interface. It stays fast for element access and is lazy for expensive operations such as repeated concatenation.
Maybe is a low-allocation alternative to Option. On Scala 3 it is an opaque type, so a present reference is stored as it is rather than inside a wrapper object, and only null and nested Maybe values are wrapped in Present. On Scala 2.13 it is a sealed trait and allocates like Option.
Combinators provides compile-time typeclasses for composing and decomposing tuples, Either types and union types, which is useful for code that must work with many shapes of the same operation.
Where to Start
Start with Chunk for sequences. Use Maybe where allocation matters and the code is on Scala 3, and Combinators when writing generic code over tuples or eithers.