英文:
What does #Task<T> indicate in an F# function signature?
问题
在以下示例代码中:
namespace MyNamespace
open System.Threading.Tasks
module MyModule =
    let handler fn = task { return! fn () }
如果我悬停在 handler 函数上,其签名是:
val handler: fn: (unit -> #Task<'b>) -> Task<'b>
我之前没有见过 #Task 这个符号。在这种情况下,# 符号的含义是什么?
英文:
In the following sample code:
namespace MyNamespace
open System.Threading.Tasks
module MyModule =
    let handler fn = task { return! fn () }
If I hover the handler function the signature is:
val handler: fn: (unit -> #Task<'b>) -> Task<'b>
I haven't see the #Task before. What is the meaning of the # sign in this case?
答案1
得分: 2
#Task<'t> 是 'a when 'a :> Task<'t> 的缩写 - 也就是说,任何 Task<'t> 的子类型。
英文:
#Task<'t> is short for 'a when 'a :> Task<'t> - that is, any subtype of Task<'t>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论