In C#:
private Task<bool> HandleRequest(HttpListenerContext context, CancellationToken ct)
To become in F#:
let HandleRequest (context:HttpListenerContext, ct:CancellationToken) =
Task.FromResult(false)
//or
let HandleRequest (context:HttpListenerContext) (ct:CancellationToken) =
Task.FromResult(false)
Now I need to invoke with
let toFunc<'I, 'T> f =
System.Func<'I,'T> f
type FunApi() as this =
inherit WebModuleBase()
do
let handle = HandleRequest |> toFunc
this.AddHandler(ModuleMap.AnyPath, HttpVerbs.Any, handle)
But I get the error:
/..../Data.fs(57,57): Error FS0001: This expression was expected to have type
'Func<HttpListenerContext,CancellationToken,Task<bool>>' but here has type
'Func<(HttpListenerContext * CancellationToken),Task<bool>>' (FS0001)