Change Please note that, as Daniel and Latin noted in the answer and comment below, this question is related to an error in F #, which seems to have been fixed in early 2014.
I am trying to write a curry wrapper for Observable.StartWith. I am using Prerelease Reactive Extensions 2.0 and the beta version of VS11. My desired result would be startWith : 'a -> IObservable<'a> -> IObservable<'a> . An obvious implementation would be something like this:
let startWith (value : 'a) (observable : IObservable<'a>) : IObservable<'a> = Observable.StartWith(observable, [| value |])
Estimated Overload Observable.StartWith StartWith<'TSource>(source : IObservable<'TSource>, params values: 'TSource[]) : IObservable<'TSource> .
The compiler creates a confusing error: This method expects a CLI 'params' parameter in this position. 'params' is a way of passing a variable number of arguments to a method in languages such as C#. Consider passing an array for this argument This method expects a CLI 'params' parameter in this position. 'params' is a way of passing a variable number of arguments to a method in languages such as C#. Consider passing an array for this argument This method expects a CLI 'params' parameter in this position. 'params' is a way of passing a variable number of arguments to a method in languages such as C#. Consider passing an array for this argument .
I am passing an array. I also tried not to pass the array, omitting [| |] [| |] , which results in a unique overload error. (Presumably due to the possibility that 'a could be System.Reactive.Concurrency.IScheduler by mapping another overload.) I also tried using F # 2.0 / VS2010, which gives the same result. I could not find any online discussion of these kinds of situations or compiler error messages.
I can't think of another way to implement this. Note that in cases where a type parameter can be specified, this is not a problem. For example, let prependZero : int -> IObservable<int> -> IObservable<int> = fun no -> o.StartWith(n) works fine. But the general version would be nice.
source share