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

Seq extensions: add tryHeadTail #176

Merged
merged 1 commit into from
Sep 17, 2021
Merged

Conversation

knocte
Copy link
Contributor

@knocte knocte commented Sep 6, 2021

FSharpLint's new recently added rule[1] complains about
function Seq.tail being a partial function, so we need
an alternative before all try-prefixed versions get
included in FSharp.Core[2]. This is not actually a
tryTail function but at least most uses of Seq.tail
use a Seq.head before it, so we can replace both calls
to Seq.(try)head & Seq.tail with a single-call to this
Seq.tryHeadTail which shouldn't be considered a partial
function anymore (even if it calls Seq.tail underneath).

Adding it in FSharpx.Collections would be a nice stopgap
instead of having to include this function in every F#
project that wants to enable this new FSharpLint rule.

[1] fsprojects/FSharpLint#453
[2] fsharp/fslang-suggestions#803

FSharpLint's new recently added rule[1] complains about
function Seq.tail being a partial function, so we need
an alternative before all try-prefixed versions get
included in FSharp.Core[2]. This is not actually a
tryTail function but at least most uses of Seq.tail
use a Seq.head before it, so we can replace both calls
to Seq.(try)head & Seq.tail with a single-call to this
Seq.tryHeadTail which shouldn't be considered a partial
function anymore (even if it calls Seq.tail underneath).

Adding it in FSharpx.Collections would be a nice stopgap
instead of having to include this function in every F#
project that wants to enable this new FSharpLint rule.

[1] fsprojects/FSharpLint#453
[2] fsharp/fslang-suggestions#803
@knocte
Copy link
Contributor Author

knocte commented Sep 17, 2021

@knocte plz merge current master into PR branch.

Rebased, thanks.

@sergey-tihon sergey-tihon merged commit 704030d into fsprojects:master Sep 17, 2021
knocte added a commit to knocte/FSharpLint that referenced this pull request Sep 17, 2021
tryLast doesn't have the same goal as tail; let's rather suggest
FSharpx.Collections.Seq.tryHeadTail extension for now, which has
just been merged [1] and will be in 3.0.0 release (at least until
we have a tryTail of some sort [2]).

[1] fsprojects/FSharpx.Collections#176
[2] fsharp/fslang-suggestions#803
knocte added a commit to knocte/FSharpLint that referenced this pull request Sep 20, 2021
tryLast doesn't have the same goal as tail; let's rather suggest
FSharpx.Collections.Seq.tryHeadTail extension for now, which has
just been merged [1] and will be in 3.0.0 release (at least until
we have a tryTail of some sort [2]).

[1] fsprojects/FSharpx.Collections#176
[2] fsharp/fslang-suggestions#803
duckmatt pushed a commit to fsprojects/FSharpLint that referenced this pull request Sep 20, 2021
tryLast doesn't have the same goal as tail; let's rather suggest
FSharpx.Collections.Seq.tryHeadTail extension for now, which has
just been merged [1] and will be in 3.0.0 release (at least until
we have a tryTail of some sort [2]).

[1] fsprojects/FSharpx.Collections#176
[2] fsharp/fslang-suggestions#803
@knocte
Copy link
Contributor Author

knocte commented Sep 26, 2021

@sergey-tihon Thanks for merging!

BTW, do you mind releasing a new 3.0 version? Otherwise, I can't consume this (I've tried to consume the pre-release, but hit a problem which I filed as an issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants