fsprojects / FSharp.Control.TaskSeq

A computation expression and module for seamless working with IAsyncEnumerable<'T> as if it is just another sequence
MIT License
91 stars 7 forks source link

Implement `TaskSeq.where` and `TaskSeq.whereAsync` #217

Closed abelbraaksma closed 8 months ago

abelbraaksma commented 8 months ago

Part if the #208 push for functions.

Add TaskSeq.where and TaskSeq.whereAsync as aliases to filter and filterAsync, similar to how Seq does that in F# Core.

The following signatures will be added:

val where: predicate: ('T -> bool) -> source: TaskSeq<'T> -> TaskSeq<'T>
val whereAsync: predicate: ('T -> #Task<bool>) -> source: TaskSeq<'T> -> TaskSeq<'T>

these behave identical to their filter equivalents.

bartelink commented 8 months ago

I (don't really) hate to be a whiner, but I detest this alias in FSharp.Core, so would prefer it not to be implemented here (and deprecated there).

(If I could have chosen only one name from the off, it would have been where, but IMO filter is de facto idiomatic, and having names matching System.Linq.Enumerable is not something that helps Seq or the other modules.)

I do get that if the rule is that it's following Seq, so logically this should be done (but you can't make me like it!)