I'm learning F# and would like to write simple F# library which can be consumed from C# application. It works as expected for trivial F# functions e.g.
let Square x = x * x
From C# I can consume it and get the expected value:
var sqaredNumber = MyFSharpLibrary.Square(5);
However when I use a Sequence
/ IEnumerable<T>
as function parameter I got FSharpFunc
object instead of the result.
Here is my function:
let FilterEvenNumbers input = Seq.filter(fun x -> x % 2 = 0)
And this is how I try to use it from C# code:
var numbers = new int[] { 1, 2, 3, 4 };
var filteredNumbers = MyFSharpLibrary.FilterEvenNumbers(numbers);
Instead of value filteredNumbers
contains FSharpFunc
object. I could use method Invoke
on that object but would like to avoid extra complexity.
How can I achieve that ?