f# - How to force a constraint on a member's return type -
i trying force constraint on function such type of first parameter has member returns async<'t>
follows:
let inline private f (a : ^t) = (^t : (static member g : string -> ^t async) t)
however, getting compiler error t not defined. possible define constraint in manner?
you're using "member constraint invocation expression" , member requires string input, you've got unbound identifier. if want invoke method put string in place of identifier t
.
if want constrain type parameter not invoke member this:
let inline private f (a : ^t when ^t : (static member g : string -> ^t async) = ...
but you'll need fill in body something.
Comments
Post a Comment