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

Correct Observable.filteri bug and optimise Observable.mapi #72

Merged
merged 6 commits into from
Jan 9, 2016
Merged

Correct Observable.filteri bug and optimise Observable.mapi #72

merged 6 commits into from
Jan 9, 2016

Conversation

anton-pt
Copy link
Contributor

Corrected the definition of Observable.filteri which previously only took a predicate of type 'T -> bool and simplified the definition of Observable.mapi, also improving performance.

Observable.filteri previously only took a predicate of type 'T -> bool
and behaved identically to Observable.filter. The corrected version
takes a predicate of type int -> 'T -> bool, matching the convention set
by the F# standard library.
Previously, Observable.mapi was defined using Observable.scan and
Observable.map, resulting in an unnecessary performance loss. The new
definition is simpler and directly calls the correct overload of the
Reactive extensions Observable.Select method.
@@ -560,7 +560,7 @@ module Observable =
/// Filters the observable elements of a sequence based on a predicate by
/// incorporating the element's index
let filteri predicate (source: IObservable<'T>) =
Observable.Where( source, Func<_,_> predicate )
Observable.Where( source, Func<_,_,_> (fun i x -> predicate x i) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have a test or something for this...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and great catch!

@anton-pt
Copy link
Contributor Author

Hmmm, so I was thinking of bringing in FsCheck to do the tests but to do so I need to upgrade the project to .NET 4.5. Any objections?

@cloudRoutine
Copy link
Member

by all means please do

@panesofglass
Copy link
Collaborator

👍

Changed target framework to 4.5.2
Updated FSharp.Core to version 4.0.0.1
Updated various dependencies to their latest version
@anton-pt
Copy link
Contributor Author

anton-pt commented Jan 3, 2016

Anything else needed before this is ready to be merged in? Sorry: I don't have a lot of experience contributing to OSS and doing unit testing....

@@ -9,7 +9,7 @@
<OutputType>Library</OutputType>
<RootNamespace>FSharp.Control.Reactive</RootNamespace>
<AssemblyName>FSharp.Control.Reactive</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@panesofglass I'm cool with upgrading the framework version to 4.5.2 and FSharp.Core to 4.0 if you are

@smoothdeveloper
Copy link

FSharp Core 4.0 works with Framework 4.0.

I'm not using this library at this moment, but I do maintain software that needs to ship for .NET 4.0.

If you are changing the framework just because of most recent FSharp.Core that might not be the right decision.

Maybe tests can be put in a separate project which targets 4.5.2?

@anton-pt
Copy link
Contributor Author

anton-pt commented Jan 8, 2016

@smoothdeveloper valid point: there should be no need for the main project to change, only the test project. I think it was FsCheck that required 4.5. I will roll back the main project to 4.0 when I get a chance.

@cloudRoutine
Copy link
Member

@anton-pt once you fix the framework settings this is good to merge

Reverted to .NET framework 4.0 for main project while keeping the test
project on version 4.5.2 in order to use FsCheck. Updated dependencies.
@anton-pt
Copy link
Contributor Author

anton-pt commented Jan 9, 2016

I made the change, however I ran into a problem. I believe that it's the same issue discussed here. It's a bit over my head to fix but, in that discussion, @forki mentions that there is a way to do so?

@cloudRoutine cloudRoutine merged commit 3158ae8 into fsprojects:master Jan 9, 2016
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.

5 participants