Hyperlinkv0.8.0-beta.28

Newtype

Newtype.valueconsteffect/Newtype.ts:144
<N extends Newtype.Any>(newtype: N): Newtype.Carrier<N>

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"
gettersmakeIso
Source effect/Newtype.ts:1441 lines
export const value: <N extends Newtype.Any>(newtype: N) => Newtype.Carrier<N> = cast
Referenced by 1 symbols