(input: unknown): Result.Result<symbol, unknown>A predefined filter that only passes through Symbol values.
constructors
Source effect/Filter.ts:4181 lines
export const const symbol: Filter<unknown, symbol>A predefined filter that only passes through Symbol values.
symbol: interface Filter<in Input, out Pass = Input, out Fail = Input>Represents a filter function that can transform inputs to outputs or filter them out.
Details
A filter takes an input value and either returns a boxed pass value or the
special fail type to indicate the value should be filtered out.
Example (Defining a positive number filter)
import { Filter, Result } from "effect"
// A filter that only passes positive numbers
const positiveFilter: Filter.Filter<number> = (n) => n > 0 ? Result.succeed(n) : Result.fail(n)
console.log(positiveFilter(5)) // Result.succeed(5)
console.log(positiveFilter(-3)) // Result.fail(-3)
Filter<unknown, symbol> = const fromPredicate: {
<A, B extends A>(
refinement: Predicate.Refinement<A, B>
): Filter<
A,
B,
EqualsWith<A, B, A, Exclude<A, B>>
>
<A>(
predicate: Predicate.Predicate<A>
): Filter<A>
}
fromPredicate(import PredicatePredicate.function isSymbol(
input: unknown
): input is symbol
Checks whether a value is a symbol.
When to use
Use when you need a Predicate guard to narrow an unknown value to a
symbol.
Details
Uses typeof input === "symbol".
Example (Guarding symbols)
import { Predicate } from "effect"
const data: unknown = Symbol.for("id")
if (Predicate.isSymbol(data)) {
console.log(data.description)
}
isSymbol)