Skip to content

Instantly share code, notes, and snippets.

@haacked
Created January 5, 2014 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haacked/8274988 to your computer and use it in GitHub Desktop.
Save haacked/8274988 to your computer and use it in GitHub Desktop.
Rx pipelining with F#
open System
open System.Reactive
open System.Reactive.Linq
let seq = [1; 2; 3; 4].ToObservable()
// Add curryable versions of Rx methods
let select (selector:'TSource -> 'TResult) (source:IObservable<'TSource>) =
Observable.Select(source, selector)
let where (predicate:'TSource -> bool) (source:IObservable<'TSource>) =
Observable.Where(source, predicate)
let newSeq = seq |>
where (fun num -> num % 2 = 0) |>
select (fun num -> num + 1)
ignore(newSeq.Subscribe(fun item -> printfn "%d" item))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment