-
Notifications
You must be signed in to change notification settings - Fork 78
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
knocte
force-pushed
the
tryHeadTail
branch
3 times, most recently
from
September 6, 2021 11:23
5f0af48
to
b7378f3
Compare
jackfoxy
approved these changes
Sep 16, 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
Rebased, thanks. |
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
@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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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