Skip to content

make exists a type predicate #1952

@codingedgar

Description

@codingedgar

🚀 Feature request

Current Behavior

export declare const exists: <A>(predicate: Predicate<A>) => (ma: Option<A>) => boolean

Desired Behavior

export declare const exists: <A>(predicate: Predicate<A>) => (ma: Option<A>) => ma is Some<A>

Who does this impact? Who is this for?

exists does not provide enough information to typescript, which prevents narrowing when used with libraries like ts-pattern or in plain code.

Describe alternatives you've considered

I'm not sure if this is enough or if another function might be better, because if exists returns false it doesn't mean ma is not Some<A>, but if it return true, it must be, right?

Your environment

Software Version(s)
fp-ts 2.16.2
TypeScript 5.6.0-beta

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions