I would be inclined to reject the idea that you should not expose functions as arguments in a library exposed to C #, and this is becoming quite common, you only need to take a look at LINQ, TPL, etc. I donβt think that too many C # developers will be scared by this.
I would, however, suggest that you avoid exposing career functions to C # arguments, since they are generally not convenient to use.
You can pretty easily wrap your algorithm in a function that takes arguments in a form by form and provides System.Func and System.Action for C #.
let csAlgo (initialisationFunc : System.Func<'a>, modificationFunc : System.Action<'a>, n : int) = algo (initialisationFunc.Invoke) (modificationFunc.Invoke) n
in C # you could do this:
var res = Module.csAlgo(() => new UserType(0), t => t.Time = t.Time + 1, 16);
You can also use the CompiledName attribute as a small span so that you can get your legend in each language. Mark your function
[<CompiledName("ExampleFunction")>] let exampleFunction () = 1
Then in C # it looks like this:
var num = Module.ExampleFunction();
Theinnerlight
source share