-
Notifications
You must be signed in to change notification settings - Fork 125
Open
Description
Overview
Add a new combinators module providing foundational typeclasses for tuple and sum type operations. These are zero-dependency building blocks used by the schema module and other parts of ZIO Blocks.
Typeclasses
Combiner[L, R]
Bidirectional tuple flattening with combine() and separate().
val c = Combiner[Int, String]
val combined = c.combine(42, "hello") // (42, "hello")
val (num, str) = c.separate(combined) // recovers original partsZippable[A, B]
One-way tuple flattening with zip() and discard flags. Supports ZIO-style *>, <*, <*> operators.
val z = Zippable[Int, String]
z.zip(42, "hello") // (42, "hello")EitherAlternator[L, R]
Either-based alternation for sum types. Works cross-version (Scala 2 + 3).
val alt = EitherAlternator[Int, String]
alt.left(42) // Left(42)
alt.right("x") // Right("x")UnionAlternator[L, R] (Scala 3 only)
Union type alternation (L | R). Rejects same-type combinations since A | A = A.
val alt = UnionAlternator[Int, String]
alt.left(42) // 42: Int | String
alt.right("x") // "x": Int | StringStructuralCombiner[A, B] (JVM only, Scala 3 only)
Macro-based structural type merging for combining record-like types.
Module Structure
combinators/
├── jvm/src/main/scala-3/ # StructuralCombiner (JVM-only macro)
├── shared/src/main/scala-2/ # Scala 2 implementations
├── shared/src/main/scala-3/ # Scala 3 implementations
└── shared/src/test/ # Cross-version tests
Acceptance Criteria
- All typeclasses implemented for Scala 2.13 and Scala 3
- Full test coverage
- Cross-platform support (JVM/JS/Native where applicable)
- Zero external dependencies
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels