effect-io-ai

Package: effect
Module: Newtype

Newtype.value

Unwraps a newtype value, returning the underlying carrier value.

When to use

Use when you need the carrier value from an existing newtype without constructing a new newtype value at the same call site.

Details

This has zero runtime cost because it is an identity cast.

Example (Unwrapping a newtype)

import { Newtype } from "effect"

interface Label extends Newtype.Newtype<"Label", string> {}

const iso = Newtype.makeIso<Label>()
const label = iso.set("hello")

const raw: string = Newtype.value(label) // "hello"

See

Signature

declare const value: <N extends Newtype.Any>(newtype: N) => Newtype.Carrier<N>

Source

Since v4.0.0