zio.blocks

zio.blocks
package zio.blocks

Members list

Packages

ZIO Blocks Async — a lightweight asynchronous effect type.

ZIO Blocks Async — a lightweight asynchronous effect type.

An Async[A] is a (possibly suspended) computation that eventually yields an A or fails with a Throwable. Create one with async.Async.succeed, async.Async.fail, async.Async.attempt, or async.Async.promise; a bare A is not itself an Async[A]. Transform and combine values with the extension methods (map, flatMap, catchAll, await, ...) brought into scope by importing this package.

==Quick start==

 import zio.blocks.async._

 // completes immediately with 42
 val a: Async[Int] = Async.promise[Int](c => c.succeed(42))

 // ops + block for the result
 val n: Int = a.map(_ + 1).block

Attributes

package zio.blocks.docs

ZIO Blocks Markdown - A pure Scala GFM library.

ZIO Blocks Markdown - A pure Scala GFM library.

This package provides a complete implementation of GitHub Flavored Markdown with a type-safe ADT, strict parser, renderer, and compile-time validated string interpolator.

==Quick Start==

 import zio.blocks.docs._

 // Parse markdown
 val doc = Parser.parse("# Hello *world*")

 // Render to string
 val md = Renderer.render(doc.toOption.get)

 // Use the interpolator
 val name = "World"
 val greeting = md"# Hello $$name"

==String Interpolator== The md interpolator validates markdown at compile time and supports interpolation of any type with a ToMarkdown instance.

 val title = "My Doc"
 val count = 42
 val doc = md"""
   # $$title

   There are $$count items.
 """

==Core Types==

  • Doc - A complete markdown document
  • Block - Block-level elements (headings, paragraphs, lists, etc.)
  • Inline - Inline elements (text, emphasis, links, etc.)
  • Parser - Strict GFM parser
  • Renderer - GFM renderer

==GFM Support== Supports all GitHub Flavored Markdown features including:

  • ATX headings, code blocks, thematic breaks
  • Block quotes, lists (ordered, unordered, task lists)
  • Tables with alignment
  • Inline formatting (emphasis, strong, strikethrough, code)
  • Links, images, autolinks
  • HTML blocks and inline HTML

Attributes

package zio.blocks.html
package zio.blocks.jwt
package zio.blocks.mux

Schemas of Scala types and what is built on them: codecs, dynamic values, optics, patches and migrations. Importing the package with import zio.blocks.schema._ also brings in the extension syntax (toJsonString, fromJson, diff, ...) and the p"..." path interpolator.

Schemas of Scala types and what is built on them: codecs, dynamic values, optics, patches and migrations. Importing the package with import zio.blocks.schema._ also brings in the extension syntax (toJsonString, fromJson, diff, ...) and the p"..." path interpolator.

On Scala 3 the path interpolator is an extension method named p, so with both import zio.blocks.schema._ and import zio.blocks.html._ in scope a call to the HTML element p(...) is ambiguous. Write that element as zio.blocks.html.p(...), or import only the names you need from one of the two packages.

Attributes

See also

Scope: A compile-time safe resource management library using scope-local opaque types.

Scope: A compile-time safe resource management library using scope-local opaque types.

==Quick Start==

import zio.blocks.scope._

Scope.global.scoped { scope =>
 import scope._
 val db: $[Database] = allocate(Resource[Database])
 val result: $[Int] = (scope $ db)(_.query("SELECT 1"))
 result  // Returns $[Int], unwrapped to Int at boundary
}

==Key Concepts==

  • '''Scoped values''' (scope.$[A]): Values tied to a scope, preventing escape
  • '''import scope._''': Bring scope operations into lexical scope
  • '''allocate(resource)''': Allocate a value in the current scope
  • '''(scope $ value)(f)''': Apply a function to a scoped value
  • '''scoped { s => ... }''': Create a child scope
  • '''defer { ... }''': Register cleanup to run when scope closes

==How It Works==

Each scope has its own $[A] opaque type. Child scopes create structurally incompatible $[A] types, preventing sibling-scoped values from being mixed. Parent-scoped values can be lowered into child scopes via lower().

The .scoped method requires Unscoped[A] evidence on the return type, ensuring only pure data (not resources or closures) can escape.

Attributes

See also

scope.Scope for scope types and operations scope.Resource for creating scoped values scope.Unscoped for types that can cross scope boundaries

package zio.blocks.sql
In this article