effect-io-ai

Package: effect
Module: Formatter

Formatter.Formatter

A callable interface representing a function that converts a Value into a Format, which defaults to string.

When to use

Use when you want to type a formatting or rendering function generically, or when you are building a pipeline that accepts pluggable formatters.

Details

This is a pure callable type and carries no runtime implementation. It is contravariant in Value and covariant in Format.

Example (Defining a custom formatter)

import type { Formatter } from "effect"

const upper: Formatter.Formatter<string> = (s) => s.toUpperCase()

console.log(upper("hello"))
// HELLO

See

Signature

export interface Formatter<in Value, out Format = string> {
  (value: Value): Format
}

Source

Since v4.0.0