effect-io-ai

Package: effect
Module: Option

Option.andThen

Chains two Options together. The second Option can either be a static value or depend on the result of the first Option.

Details

This function enables sequencing of two Option computations. If the first Option is Some, the second Option is evaluated. The second Option can either:

If the first Option is None, the function skips the evaluation of the second Option and directly returns None.

Signature

declare const andThen: { <A, B>(f: (a: A) => Option<B>): (self: Option<A>) => Option<B>; <B>(f: Option<B>): <A>(self: Option<A>) => Option<B>; <A, B>(f: (a: A) => B): (self: Option<A>) => Option<B>; <B>(f: NotFunction<B>): <A>(self: Option<A>) => Option<B>; <A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B>; <A, B>(self: Option<A>, f: Option<B>): Option<B>; <A, B>(self: Option<A>, f: (a: A) => B): Option<B>; <A, B>(self: Option<A>, f: NotFunction<B>): Option<B>; }

Source

Since v2.0.0