Package: effect
Module: Optic
Creates an Iso from a pair of conversion functions.
When to use
Use when you have two pure conversion functions that preserve all information
between S and A.
Details
The returned optic can be composed with any other optic.
Example (Wrapping and unwrapping a branded type)
import { Optic } from "effect"
type Meters = { readonly value: number }
const meters = Optic.makeIso<Meters, number>(
(m) => m.value,
(n) => ({ value: n })
)
console.log(meters.get({ value: 100 }))
// Output: 100
console.log(meters.set(42))
// Output: { value: 42 }
See
Iso — the type this function returnsid — identity iso (no conversion)Signature
declare const makeIso: <S, A>(get: (s: S) => A, set: (a: A) => S) => Iso<S, A>
Since v4.0.0