(value: Value): FormatA 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"))
// HELLOexport interface interface Formatter<in Value, out Format = string>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
Formatter<in function (type parameter) Value in Formatter<in Value, out Format = string>Value, out function (type parameter) Format in Formatter<in Value, out Format = string>Format = string> {
(value: in Valuevalue: function (type parameter) Value in Formatter<in Value, out Format = string>Value): function (type parameter) Format in Formatter<in Value, out Format = string>Format
}