Hyperlinkv0.8.0-beta.28

Optic

Optic.idfunctioneffect/Optic.ts:1470
<S>(): Iso<S, S>

Iso that focuses on the whole value unchanged.

When to use

Use when you need to start an optic chain with a focus on the whole value.

Details

  • get(s) returns s.
  • set(a) returns a.
  • Singleton — every call returns the same instance.

Example (Starting an optic chain)

import { Optic } from "effect"

type S = { readonly x: number }

const _x = Optic.id<S>().key("x")

console.log(_x.get({ x: 42 }))
// Output: 42
IsoIso
Source effect/Optic.ts:14703 lines
export function id<S>(): Iso<S, S> {
  return identityIso
}
Referenced by 2 symbols