-
Notifications
You must be signed in to change notification settings - Fork 21
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
chooseType for List, Array and Seq modules #527
Comments
I'd like to vote for Module Seq =
let ofType<'a> (items: _ seq)= items |> Seq.choose(fun i -> match box i with | :? 'a as a -> Some a |_ -> None) I think this makes it discoverable, and where people might expect to find it. |
Nice suggestion! I assume this is a relatively small feature, so could this be something that someone new to the F# compiler (like me) can pick up? If so, I'd love to give it a go. |
Has this been approved yet? |
@Happypig375 Nope, that requires the |
@cartermp What do you think about this?
So I'd say yes, we could do this, there's no real reason not to |
My only question would be if this is also considered valid for Fable usage, but otherwise I don't see a reason not to add this |
Fable can test the run-time type limited to classes.
|
It’s reasonable to have such functions at core library when you do interop with frameworks like Xamarin, where you sometimes have to get a collection of a more concrete type. Or find first element that satisfies some type. Example is |
This should be called |
The RFC has been archived as we decided not to progress it. I will close this suggestion as declined |
Enumerable.OfType equivalent for List, Array and Seq modules
I propose to extend
List
,Array
andSeq
modules with equivalent to Enumerable.OfTypeThe existing way of approaching this problem in F# is
more options a mentioned on StackOverflow
Pros and Cons
The advantages of making this adjustment to F# are:
The disadvantages of making this adjustment to F#
Extra informtion
Estimated cost (XS, S, M, L, XL, XXL): XS
Related suggestions: (put links to related suggestions here)
Affidavit (must be submitted)
Please tick this by placing a cross in the box:
Please tick all that apply:
The text was updated successfully, but these errors were encountered: