Effect<A, E, R>
ZIO[-R, +E, +A](Type parameter order is different: Effect puts Success (A) first, while ZIO puts Environment (R) first)
Effect.succeed(x)
ZIO.succeed(x)(Creates a successful effect with the given value)
Effect.fail(e)
ZIO.fail(e)(Creates a failed effect with the given error)
Effect.try(() => ...)
ZIO.attempt(...)(Wraps a synchronous operation that may throw)
Effect.sync(() => ...)
ZIO.suspend(...)(Defers evaluation of a thunk (side-effecting code))
Effect.catchAll(fa, f)
fa.catchAll(f)(Handle all errors with a recovery function)
Effect.orElse(fa, () => fb)
fa.orElse(fb)(Run fallback effect if first fails)
Effect.mapError(fa, f)
fa.mapError(f)(Transform the error type)
Effect.either(fa)
fa.either(Convert Effect<A, E, R> to Effect<Either<E, A>, never, R>)
Effect.die(defect)
ZIO.die(defect)(Create a fatal defect (not in the typed error channel))
Effect.gen(function* () { ... })
for { ... } yield ...(Sequential composition with generators. Use yield* to unwrap effects)
yield* effect
<- effect (in for-comprehension)(Bind/unwrap an effect in a generator)
Effect.map(fa, f)
fa.map(f)(Transform the success value)
Effect.flatMap(fa, f)
fa.flatMap(f)(Chain effects (bind))
class Tag extends Context.Tag
ZIO.service[T](Define service tags with Context.Tag class pattern)
yield* ServiceTag
ZIO.service[ServiceType](Access a service in Effect.gen)
Layer.succeed(Tag, impl)
ZLayer.succeed(impl)(Create a layer from a service implementation)
Layer.effect(Tag, effect)
ZLayer.fromEffect(...)(Create a layer from an effect)
Layer.provide(inner, outer)
outer >>> inner(Horizontal layer composition (dependencies))
Layer.merge(layer1, layer2)
layer1 ++ layer2(Vertical layer composition (merge independent layers))
Effect.provide(effect, layer)
effect.provideLayer(layer)(Provide layers to an effect)
Layer.scoped(Tag, effect)
ZLayer.scoped(...)(Create a layer with scoped resource management)
Effect.fork(fa)
fa.fork(Run effect concurrently in a fiber)
Fiber.join(fiber)
fiber.join(Wait for fiber to complete and get result)
Fiber.interrupt(fiber)
fiber.interrupt(Cancel a running fiber)
Effect.all(effects, { concurrency })
ZIO.collectAllPar(effects)(Run effects in parallel with concurrency control)
Effect.race(fa, fb)
fa.race(fb)(Run both effects, return result of first to succeed)
Ref.make(initial)
Ref.make(initial)(Create atomic reference for concurrent state)
Ref.get/set/update(ref, ...)
ref.get/set/update(Atomic operations on Ref)
Stream<A, E, R>
ZStream[-R, +E, +O](Stream type with Output (A) first, unlike ZStream)
Stream.succeed(...)
ZStream(...)(Create stream from values)
Stream.map/flatMap/filter(stream, f)
stream.map/flatMap/filter(Stream transformations use pipe syntax)
Stream.runCollect(stream)
stream.runCollect(Collect stream elements into array)
Sink.count/last/...
ZSink.count/last/...(Aggregators for stream consumption)
Schema<A>
Schema[A](Runtime type validation and transformation)
Schema.decodeUnknown(schema)(data)
schema.decode(data)(Parse/validate unknown data into typed value)
Schema.optional(Schema.String)
Option[String](Optional/nullable field in schema)
HttpClient service
Client.service (ZIO HTTP)(HTTP client service from @effect/platform)
client.get/post(url, options)
Client.get/post(url, ...)(HTTP methods return HttpClientResponse effect)
response.json/text
response.body.asString(Get response body as parsed JSON or text)
SqlClient service
JdbcService (ZIO JDBC)(Database client service from @effect/sql)
sql`SELECT ... WHERE id = ${id}`
sql"SELECT ... WHERE id = $id"(Template literal SQL with automatic parameterization)
SqlClient.transaction(effect)
jdbc.transaction { ... }(Run effects in a database transaction)