Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please implement TaskSeq.tryItem, tryLast, tryHead, tryPick, tryFind and the non-try counterparts #22

Closed
abelbraaksma opened this issue Oct 13, 2022 · 3 comments
Labels
enhancement New feature or request topic: surface area Adds functions to the public surface area
Milestone

Comments

@abelbraaksma
Copy link
Member

abelbraaksma commented Oct 13, 2022

Signatures should be similar like for Seq, with overloads for async versions so that the picker or chooser function can return a Task.

Consider:

TaskSeq.isEmpty
TaskSeq.head
TaskSeq.tryHead
TaskSeq.last
TaskSeq.tryLast
TaskSeq.tryExactlyOne
TaskSeq.exactlyOne
TaskSeq.item
TaskSeq.tryItem
TaskSeq.find + async version
TaskSeq.tryFind + async version
TaskSeq.pick + async version
TaskSeq.tryPick + async version
TaskSeq.filter + async version
TaskSeq.choose + async version

As with Seq, the non-try variants will raise an exception if the precondition is not met.

@abelbraaksma
Copy link
Member Author

abelbraaksma commented Oct 14, 2022

These 21 functions have been implemented through #23. The readme has also been updated, but for completeness sake, I'll add the signatures here as well:

val tryHead: taskSeq: taskSeq<'T> -> Task<'T option>
val head: taskSeq: taskSeq<'T> -> Task<'T>

val tryLast: taskSeq: taskSeq<'T> -> Task<'T option>
val last: taskSeq: taskSeq<'T> -> Task<'T>  // may raise

val tryItem: index: int -> taskSeq: taskSeq<'T> -> Task<'T option>
val item: index: int -> taskSeq: taskSeq<'T> -> Task<'T>  // may raise

val tryExactlyOne: source: taskSeq<'T> -> Task<'T option>
val exactlyOne: source: taskSeq<'T> -> Task<'T>  // may raise

val choose: chooser: ('T -> 'U option) -> source: taskSeq<'T> -> taskSeq<'U>
val chooseAsync: chooser: ('T -> #Task<'U option>) -> source: taskSeq<'T> -> taskSeq<'U>
val filter: predicate: ('T -> bool) -> source: taskSeq<'T> -> taskSeq<'T>
val filterAsync: predicate: ('T -> #Task<bool>) -> source: taskSeq<'T> -> taskSeq<'T>

val tryPick: chooser: ('T -> 'U option) -> source: taskSeq<'T> -> Task<'U option>
val tryPickAsync: chooser: ('T -> #Task<'U option>) -> source: taskSeq<'T> -> Task<'U option>
val pick: chooser: ('T -> 'U option) -> source: taskSeq<'T> -> Task<'U>  // may raise
val pickAsync: chooser: ('T -> #Task<'U option>) -> source: taskSeq<'T> -> Task<'U>  // may raise

val tryFind: predicate: ('T -> bool) -> source: taskSeq<'T> -> Task<'T option>
val tryFindAsync: predicate: ('T -> #Task<bool>) -> source: taskSeq<'T> -> Task<'T option>
val find: predicate: ('T -> bool) -> source: taskSeq<'T> -> Task<'T>  // may raise
val findAsync: predicate: ('T -> #Task<bool>) -> source: taskSeq<'T> -> Task<'T>  // may raise

@abelbraaksma
Copy link
Member Author

Prematurely closed, test CI is currently not running. Let's wait until it works again.

@abelbraaksma abelbraaksma reopened this Oct 14, 2022
@abelbraaksma
Copy link
Member Author

The above functions have been implemented through #23.

@abelbraaksma abelbraaksma added enhancement New feature or request topic: surface area Adds functions to the public surface area labels Oct 22, 2022
@abelbraaksma abelbraaksma added this to the v0.1.0 milestone Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic: surface area Adds functions to the public surface area
Projects
None yet
Development

No branches or pull requests

1 participant