make exists a type predicate
Author: codingedgarCreated Aug 27, 2024Updated Aug 27, 2024
Feature request
Current Behavior
export declare const exists: <A>(predicate: Predicate<A>) => (ma: Option<A>) => booleanDesired 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 |
Source: gcanti/fp-ts