function / @typed/fx

Sink.compact

Forwards Some values and discards None values.

Package version
2.0.0-beta.13
Category
Selecting inputs
Since
1.0.0
Member of
Sink

Import

import { Sink } from "@typed/fx";

Access Sink.compact through the imported Sink export. Its declaration below describes the member.

This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.

Signatures

export declare function compact<A, E, R>(sink: Sink<A, E, R>): Sink<Option.Option<A>, E, R>;

Why

compact consumes optional producer output with the same zero-or-one cardinality as filterMap.

Ownership and lifetime

Option inspection is synchronous and resource-free. Present values retain arrival order; failure causes pass through unchanged.

Examples

import { Effect, Option } from "effect"
import * as Sink from "@typed/fx/Sink"
const sink = Sink.compact(Sink.make(Effect.logError, (n: number) => Effect.log(n)))
sink.onSuccess(Option.some(1))

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source