effect-io-ai

Package: @effect/printer
Module: Doc

Doc.nest

Lays out a document with the current nesting level (indentation of the following lines) increased by the specified indent. Negative values are allowed and will decrease the nesting level accordingly.

See also:

Example

import * as assert from "node:assert"
import * as Doc from "@effect/printer/Doc"
import { pipe } from "effect/Function"
import * as String from "effect/String"

const doc = Doc.vsep([
  pipe(Doc.vsep(Doc.words("lorem ipsum dolor")), Doc.nest(4)),
  Doc.text("sit"),
  Doc.text("amet")
])

assert.strictEqual(
  Doc.render(doc, { style: "pretty" }),
  String.stripMargin(
    `|lorem
     |    ipsum
     |    dolor
     |sit
     |amet`
  )
)

Signature

declare const nest: { (indent: number): <A>(self: Doc<A>) => Doc<A>; <A>(self: Doc<A>, indent: number): Doc<A>; }

Source

Since v1.0.0