index overview
Added in v1.0.0
Table of contents
- constructors
- utils
- Fold (interface)
- Getter (interface)
- Iso (interface)
- Lens (interface)
- Optic (interface)
- Optional (interface)
- PolyIso (interface)
- PolyLens (interface)
- PolyOptional (interface)
- PolyPrism (interface)
- PolyReversedPrism (interface)
- PolySetter (interface)
- PolyTraversal (interface)
- Prism (interface)
- ReversedPrism (interface)
- Setter (interface)
- Traversal (interface)
- decode
- encode
- get
- getOption
- getOrModify
- modify
- polyReversedPrism
- replace
- replaceOption
- reversedPrism
constructors
cons
An optic that accesses the Cons
case of a ReadonlyArray
.
Signature
export declare const cons: {
<A>(): Prism<readonly A[], readonly [A, readonly A[]]>
<A, B>(): PolyPrism<readonly A[], readonly B[], readonly [A, readonly A[]], readonly [B, readonly B[]]>
}
Added in v1.0.0
findFirst
An optic that accesses the first case specified by a predicate.
Signature
export declare const findFirst: {
<C extends A, B extends A, A = C>(refinement: Refinement<A, B>, message?: string): Optional<readonly C[], B>
<B extends A, A = B>(predicate: Predicate<A>, message?: string): Optional<readonly B[], B>
}
Added in v1.0.0
head
Signature
export declare const head: <A>() => Optional<readonly A[], A>
Added in v1.0.0
id
The identity optic.
Signature
export declare const id: { <S>(): Iso<S, S>; <S, T>(): PolyIso<S, T, S, T> }
Added in v1.0.0
indexes
An optic that accesses all of the elements in a ReadonlyArray
.
Signature
export declare const indexes: <A>() => Traversal<readonly A[], A>
Added in v1.0.0
iso
Signature
export declare const iso: {
<S, A>(get: (s: S) => A, encode: (a: A) => S): Iso<S, A>
<S, T, A, B>(get: (s: S) => A, encode: (b: B) => T): PolyIso<S, T, A, B>
}
Added in v1.0.0
lens
Signature
export declare const lens: {
<S, A>(get: (s: S) => A, set: (a: A) => (s: S) => S): Lens<S, A>
<S, T, A, B>(get: (s: S) => A, set: (b: B) => (s: S) => T): PolyLens<S, T, A, B>
}
Added in v1.0.0
optional
Signature
export declare const optional: <S, A>(
decode: (s: S) => Either.Either<A, Error>,
replaceEither: (a: A) => (s: S) => Either.Either<S, Error>
) => Optional<S, A>
Added in v1.0.0
polyOptional
Signature
export declare const polyOptional: <S, T, A, B>(
polyDecode: (s: S) => Either.Either<A, readonly [Error, T]>,
polyReplaceEither: (b: B) => (s: S) => Either.Either<T, readonly [Error, T]>
) => PolyOptional<S, T, A, B>
Added in v1.0.0
polyPrism
Signature
export declare const polyPrism: <S, T, A, B>(
polyDecode: (s: S) => Either.Either<A, readonly [Error, T]>,
encode: (b: B) => T
) => PolyPrism<S, T, A, B>
Added in v1.0.0
polyTraversal
Signature
export declare const polyTraversal: <S, T, A, B>(
decode: (s: S) => Either.Either<readonly A[], readonly [Error, T]>,
replace: (bs: readonly B[]) => (s: S) => Either.Either<T, readonly [Error, T]>
) => PolyTraversal<S, T, A, B>
Added in v1.0.0
prism
Signature
export declare const prism: <S, A>(decode: (s: S) => Either.Either<A, Error>, encode: (a: A) => S) => Prism<S, A>
Added in v1.0.0
reversedFilter
An optic that accesses the input case specified by a predicate.
Signature
export declare const reversedFilter: {
<A, S extends A>(refinement: Refinement<A, S>, message?: string): ReversedPrism<S, A>
<S>(predicate: Predicate<S>, message?: string): ReversedPrism<S, S>
}
Added in v1.0.0
tail
Signature
export declare const tail: <A>() => Optional<readonly A[], readonly A[]>
Added in v1.0.0
traversal
Signature
export declare const traversal: <S, A>(
decode: (s: S) => Either.Either<readonly A[], Error>,
replace: (as: readonly A[]) => (s: S) => Either.Either<S, Error>
) => Traversal<S, A>
Added in v1.0.0
utils
Fold (interface)
Signature
export interface Fold<in S, out A> extends Getter<S, ReadonlyArray<A>> {}
Added in v1.0.0
Getter (interface)
Signature
export interface Getter<in S, out A> extends Optic<S, never, never, Error, unknown, A, unknown> {}
Added in v1.0.0
Iso (interface)
Signature
export interface Iso<in out S, in out A> extends PolyIso<S, S, A, A> {}
Added in v1.0.0
Lens (interface)
Signature
export interface Lens<in out S, in out A> extends PolyLens<S, S, A, A> {}
Added in v1.0.0
Optic (interface)
Signature
export interface Optic<
in GetWhole,
in SetWholeBefore,
in SetPiece,
out GetError,
out SetError,
out GetPiece,
out SetWholeAfter
> {
readonly getOptic: (GetWhole: GetWhole) => Either.Either<GetPiece, readonly [GetError, SetWholeAfter]>
readonly setOptic: (
SetPiece: SetPiece
) => (SetWholeBefore: SetWholeBefore) => Either.Either<SetWholeAfter, readonly [SetError, SetWholeAfter]>
/**
* @since 1.0.0
*/
compose<S, A, B>(this: Iso<S, A>, that: Iso<A, B>): Iso<S, B>
compose<S, T, A, B, C, D>(this: PolyIso<S, T, A, B>, that: PolyIso<A, B, C, D>): PolyIso<S, T, C, D>
compose<S, A, B>(this: Lens<S, A>, that: Lens<A, B>): Lens<S, B>
compose<S, T, A, B, C, D>(this: PolyLens<S, T, A, B>, that: PolyLens<A, B, C, D>): PolyLens<S, T, C, D>
compose<S, A, B>(this: ReversedPrism<S, A>, that: ReversedPrism<A, B>): ReversedPrism<S, B>
compose<S, T, A, B, C, D>(
this: PolyReversedPrism<S, T, A, B>,
that: PolyReversedPrism<A, B, C, D>
): PolyReversedPrism<S, T, C, D>
compose<S, A, B>(this: Prism<S, A>, that: Prism<A, B>): Prism<S, B>
compose<S, T, A, B, C, D>(this: PolyPrism<S, T, A, B>, that: PolyPrism<A, B, C, D>): PolyPrism<S, T, C, D>
compose<S, A, B>(this: Optional<S, A>, that: Optional<A, B>): Optional<S, B>
compose<S, T, A, B, C, D>(this: PolyOptional<S, T, A, B>, that: PolyOptional<A, B, C, D>): PolyOptional<S, T, C, D>
/**
* An optic that accesses the specified key of a struct or a tuple.
*
* @since 1.0.0
*/
at<S, A, Key extends keyof A>(this: Lens<S, A>, key: Key): Lens<S, A[Key]>
at<S, T, A, B, Key extends keyof A & keyof B>(this: PolyLens<S, T, A, B>, key: Key): PolyLens<S, T, A[Key], B[Key]>
at<S, A, Key extends keyof A>(this: Optional<S, A>, key: Key): Optional<S, A[Key]>
at<S, T, A, B, Key extends keyof A & keyof B>(
this: PolyOptional<S, T, A, B>,
key: Key
): PolyOptional<S, T, A[Key], B[Key]>
/**
* An optic that accesses a group of keys of a struct.
*
* @since 1.0.0
*/
pick<S, A, Keys extends readonly [keyof A, ...Array<keyof A>]>(
this: Lens<S, A>,
...keys: Keys
): Lens<S, { readonly [K in Keys[number]]: A[K] }>
pick<S, A, Keys extends readonly [keyof A, ...Array<keyof A>]>(
this: Optional<S, A>,
...keys: Keys
): Optional<S, { readonly [K in Keys[number]]: A[K] }>
/**
* An optic that excludes a group of keys of a struct.
*
* @since 1.0.0
*/
omit<S, A, Keys extends readonly [keyof A, ...Array<keyof A>]>(
this: Lens<S, A>,
...keys: Keys
): Lens<S, { readonly [K in Exclude<keyof A, Keys[number]>]: A[K] }>
omit<S, A, Keys extends readonly [keyof A, ...Array<keyof A>]>(
this: Optional<S, A>,
...keys: Keys
): Optional<S, { readonly [K in Exclude<keyof A, Keys[number]>]: A[K] }>
/**
* An optic that accesses the case specified by a predicate.
*
* @since 1.0.0
*/
filter<S, A extends B, C extends B, B = A>(
this: Prism<S, A>,
refinement: Refinement<B, C>,
message?: string
): Prism<S, C>
filter<S, A extends B, B = A>(this: Prism<S, A>, predicate: Predicate<B>, message?: string): Prism<S, A>
filter<S, A extends B, C extends B, B = A>(
this: Optional<S, A>,
refinement: Refinement<B, C>,
message?: string
): Optional<S, C>
filter<S, A extends B, B = A>(this: Optional<S, A>, predicate: Predicate<B>, message?: string): Optional<S, A>
/**
* An optic that accesses the `NonNullable` case of a nullable type.
*
* @since 1.0.0
*/
nonNullable<S, A>(this: Prism<S, A>): Prism<S, NonNullable<A>>
nonNullable<S, A>(this: Optional<S, A>): Optional<S, NonNullable<A>>
/**
* An optic that accesses the `Some` case of an `Option`.
*
* @since 1.0.0
*/
some<S, A>(this: Prism<S, Option.Option<A>>): Prism<S, A>
some<S, A>(this: Optional<S, Option.Option<A>>): Optional<S, A>
/**
* An optic that accesses the specified index of a `ReadonlyArray`.
*
* @since 1.0.0
*/
index<S, A>(this: Optional<S, ReadonlyArray<A>>, n: number): Optional<S, A>
/**
* An optic that accesses the specified key of a record.
*
* @since 1.0.0
*/
key<S, A>(this: Optional<S, Record.ReadonlyRecord<string, A>>, key: string): Optional<S, A>
}
Added in v1.0.0
Optional (interface)
Signature
export interface Optional<in out S, in out A> extends PolyOptional<S, S, A, A> {}
Added in v1.0.0
PolyIso (interface)
Signature
export interface PolyIso<in S, out T, out A, in B> extends Optic<S, unknown, B, never, never, A, T> {}
Added in v1.0.0
PolyLens (interface)
Signature
export interface PolyLens<in S, out T, out A, in B> extends Optic<S, S, B, never, never, A, T> {}
Added in v1.0.0
PolyOptional (interface)
Signature
export interface PolyOptional<in S, out T, out A, in B> extends Optic<S, S, B, Error, Error, A, T> {}
Added in v1.0.0
PolyPrism (interface)
Signature
export interface PolyPrism<in S, out T, out A, in B> extends Optic<S, unknown, B, Error, never, A, T> {}
Added in v1.0.0
PolyReversedPrism (interface)
Signature
export interface PolyReversedPrism<in S, out T, out A, in B> extends Optic<S, S, B, never, Error, A, T> {}
Added in v1.0.0
PolySetter (interface)
Signature
export interface PolySetter<in S, out T, in A> extends Optic<never, S, A, unknown, Error, unknown, T> {}
Added in v1.0.0
PolyTraversal (interface)
Signature
export interface PolyTraversal<in S, out T, out A, in B>
extends PolyOptional<S, T, ReadonlyArray<A>, ReadonlyArray<B>> {}
Added in v1.0.0
Prism (interface)
Signature
export interface Prism<in out S, in out A> extends PolyPrism<S, S, A, A> {}
Added in v1.0.0
ReversedPrism (interface)
Signature
export interface ReversedPrism<in out S, in out A> extends PolyReversedPrism<S, S, A, A> {}
Added in v1.0.0
Setter (interface)
Signature
export interface Setter<in out S, in A> extends PolySetter<S, S, A> {}
Added in v1.0.0
Traversal (interface)
Signature
export interface Traversal<in out S, in out A> extends PolyTraversal<S, S, A, A> {}
Added in v1.0.0
decode
Signature
export declare const decode: <S, T, A, B>(optic: PolyPrism<S, T, A, B>) => (GetWhole: S) => Either.Either<A, Error>
Added in v1.0.0
encode
Signature
export declare const encode: <S, T, A, B>(optic: PolyPrism<S, T, A, B>) => (SetPiece: B) => T
Added in v1.0.0
get
Signature
export declare const get: <S, T, A, B>(optic: PolyReversedPrism<S, T, A, B>) => (s: S) => A
Added in v1.0.0
getOption
Signature
export declare const getOption: <S, A>(optic: Getter<S, A>) => (s: S) => Option.Option<A>
Added in v1.0.0
getOrModify
Signature
export declare const getOrModify: <S, T, A, B>(optic: PolyOptional<S, T, A, B>) => (s: S) => Either.Either<A, T>
Added in v1.0.0
modify
Signature
export declare const modify: <S, T, A, B>(optic: PolyOptional<S, T, A, B>) => (f: (a: A) => B) => (s: S) => T
Added in v1.0.0
polyReversedPrism
Signature
export declare const polyReversedPrism: <S, T, A, B>(
get: (s: S) => A,
polyReplaceEither: (b: B) => (s: S) => Either.Either<T, readonly [Error, T]>
) => PolyReversedPrism<S, T, A, B>
Added in v1.0.0
replace
Signature
export declare const replace: <S, T, A>(optic: PolySetter<S, T, A>) => (a: A) => (s: S) => T
Added in v1.0.0
replaceOption
Signature
export declare const replaceOption: <S, T, A>(optic: PolySetter<S, T, A>) => (a: A) => (s: S) => Option.Option<T>
Added in v1.0.0
reversedPrism
Signature
export declare const reversedPrism: <S, A>(
get: (s: S) => A,
replaceEither: (a: A) => Either.Either<S, Error>
) => ReversedPrism<S, A>
Added in v1.0.0