Tail recursion for TaskSeq
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 冷清
- 技术栈
- fsharp
调研方向
从 issue 中的尾递归 asyncSeq 示例开始,并将其预期用法与 taskSeq 和 yield! 进行比较。issue 没有列出源文件或测试,也没有定义可接受的设计或完成标准;这些内容需要在实现之前确定。
由索引模型根据 Issue 内容生成。
描述
We've removed the tail recursion because it was hard to consolidate it into yield! (it was instead done with return!, which has no place in taskSeq).
However, today I helped someone with some code that he considered for taskSeq which had the following approach:
let getPoliciesAsync policyid =
asyncSeq{
use connection = new NpgsqlConnection(npgsqlConnectionStringBuilder.ConnectionString)
use command = new NpgsqlCommand($"SELECT policy_data FROM policy.tbl_policy where policy_id = {Sql.uuid policyid};", connection)
let! reader = command.ExecuteReaderAsync() |> Async.AwaitTask
let rec someRec() = asyncSeq{
let! rowExists = reader.ReadAsync() |> Async.AwaitTask
if rowExists then
yield {| dt1 = reader.GetString(0) |}
yield! someRec()
}
yield! someRec()
} |> AsyncSeq.toAsyncEnum
As you can see, it uses asyncSeq, but also: it is recursive. The same approach with taskSeq would likely be more performant, however, if there are a lot of rows, this becomes problematic. This code can be rewritten with a loop, though.
@dsyme, sharing this with you in case we want to revisit this at some point.
- 主要语言
- F#
- 星标
- 111
- 派生
- 13
- 平均合并
- 7 小时 59 分钟
- 30 天内合并 PR
- 3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fsprojects/FSharp.Control.TaskSeq 的其他 Issue
-
agentic-workflows automation repo-assist
难度 2/5 1-3 小时 新手友好度 70/100
-
agentic-workflows automation repo-assist
难度 1/5 1-3 小时 新手友好度 35/100
fsprojects/FSharp.Control.TaskSeq#476 · 1 条评论 ·
-
bug
难度 4/5 3-5 天 新手友好度 45/100
fsprojects/FSharp.Control.TaskSeq#473 · 1 条评论 ·
-
automation enhancement repo-assist
难度 5/5 一周以上 新手友好度 10/100
-
enhancement needs triage
难度 5/5 一周以上 新手友好度 45/100
查看 fsprojects/FSharp.Control.TaskSeq 的全部 Issue
相似的 Issue
-
bug CLI custom-model
难度 2/5 1-3 小时 新手友好度 75/100
-
bug confirmed issue
难度 2/5 1-3 小时 新手友好度 75/100
open-webui/open-webui#30750 · 1 条评论 ·
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
danielmiessler/LifeOS#2234 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
-
bug
难度 2/5 1-3 小时 新手友好度 75/100