I’ve got a class written in F# that I’m consuming in C#, that defines a method Render:
member this.Render template (context: IContext) = let tokens = Lexer.tokenize template let parser = new DefaultParser([for filter in _filters -> filter]) let resp = new StringBuilder() for node in parser.Parse tokens None do ignore <| resp.Append(node.render context) resp.ToString()
The signature of this method is template:string -> (IContext -> string), which of course reads as ‘member Render takes a string parameter, then returns a function that takes an IContext and produces a string.
If I change the declaration from ‘member’ to a let binding, defining it as a function local to the class definition:
let Render template (context: IContext) = ...
Then the signature becomes what you would expect it to be – string -> IContext -> string, which reads ‘Render takes a string, then an IContext and produces a string’.
Is there a way to make a member behave like the let binding? This is causing issues consuming this member from C#, as the signature becomes Render(string, FastFunc<IContext, string>), which is not overly usable.
If you want to expose to C#, you should write it tupled style:
That’ll expose a normal .NET style method.