-
Notifications
You must be signed in to change notification settings - Fork 783
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
Remove getting needless list length #12998
Conversation
src/fsharp/absil/illib.fsi
Outdated
@@ -206,6 +206,8 @@ module internal List = | |||
|
|||
val internal allEqual: xs:'T list -> bool when 'T: equality | |||
|
|||
val isSingleItem: xs: 'T list -> bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think isSingleton
is more consistent (List.isEmpty
, List.singleton
) but no big deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with @dsyme here singleton has a particular meaning in programming. isSingleItem is a bit more specific here.
It also means "list with a single element" in many functional languages, besides, we already use it in lists and arrays |
@KevinRansom, the contention is that I think the reasoning of making it the pendant of |
I've been actually choosing between |
sounds good. |
@duckmatt / @knocte / @jgardella, wondering if this wouldn't be worth a rule in FSharpLint? |
Good idea, although it would be much easier to make the violators of the rule respect it if there was an |
@dsyme, a bit tangential, I remember some code reviews where we you preferred I change Do you feel It would be cool to have such bindings turn into boolean expression, if there is no ambiguity introduced in the language and such suggestion would makes sense. |
Yes,
The general construct would be "test if something matches a pattern and return a bool". F# doesn't have this construct mainly out of simplicity, Probably |
Thanks for the feedback, I think this, and fsprojects/FSharpLint#543 would push us towards bringing the function in FSharp.Core, so FSharpLint can propose a quick fix to the issue (and embark the diagnostic about wrong code which I was concerned about). |
* Remove getting needless list length * Cleanup * Update illib.fs * List.isSingleItem -> List.isSingleton Co-authored-by: Don Syme <dsyme@users.noreply.github.com>
Removes some needless list traversals.