Named version of `mapN` and friends
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- scala
调研方向
首先阅读 issue 中链接的 Scala 3 Named Tuples 和 Structural Types 文档,然后查找 Cats 现有的 mapN 和 parMapN API。issue 没有指定文件或测试;要完成这项工作,需要确定一个用于命名 applicative 组合的 Scala 3 API,并进行相应的验证。
由索引模型根据 Issue 内容生成。
描述
I wonder if we could have a Scala 3 only version of mapN and friends that work on NamedTuples instead of plain ones.
The motivation would be to fix the major usability issue with applicative composition, where operations and the names of their results are separated.
For example, imagine a very simple for comprehension like this:
final case class Config(foo: Foo, bar: Bar, baz: Baz, quax: Quax)
object Config {
def load: IO[Config] =
for {
foo <- env(name = "FOO").as[Foo]
bar <- env(name = "BAR").as[Bar]
baz <- env(name = "BAZ").as[Baz]
quax <- env(name = "QUAX").as[Quax]
} yield Config(foo, bar, baz, quax)
}
One may realize that there is no dependency between each operation, and thus that instead of failing fast, we could try to read all env vars "concurrently" and accumulate all the errors instead:
def load: IO[Config] =
(
env(name = "FOO").as[Foo],
env(name = "BAR").as[Bar],
env(name = "BAZ").as[Baz],
env(name = "QUAX").as[Quax]
).parMapN { case (foo, bar, baz, quax) =>
Config(foo, bar, baz, quax)
}
But, this disconnects the names (foo, bar, baz, quax) from the operations that produced them; and yes, in this case, you could just do parMapN(Config.apply) but that is besides the point.
Thus, it would be great if we could use NamedTuples and maybe Structural Types to get an API like this:
def load: IO[Config] =
(
foo = env(name = "FOO").as[Foo],
bar = env(name = "BAR").as[Bar],
baz = env(name = "BAZ").as[Baz],
quax = env(name = "QUAX").as[Quax]
).namedParMapN { result =>
Config(result.foo, result.bar, result.baz, result.quax)
}
- 主要语言
- Scala
- 星标
- 5.5k
- 派生
- 1.2k
- 平均合并
- 4 天 6 小时
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
typelevel/cats 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
Next release? - 2.13.0 is 18 months old可能已有人在做 @armanbilge 于 5 天前认领。 未关闭
typelevel/cats#4910 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
typelevel/cats#4871 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 30/100
维护者通常 1 天内回复
-
Typeclass instances for `ZipLazyList` and `ZipStream` seem to be unlawful可能重新可做 @satorg 于 208 天前认领,目前没有进行中的 PR。 未关闭
typelevel/cats#4830 · 12 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
arrays_zip with two same-named inputs fails with "ArrowArray struct has 2 children (expected 1)"未关闭bug requires-triage
难度 2/5 1-3 小时 新手友好度 78/100
apache/datafusion-comet#6251 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
lichess-org/lila#21826 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
ergoplatform/ergo#2579 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
x:action/improve x:size/tiny x:type/content
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复