Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Named version of `mapN` and friends

オープン
#4,792 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
scala

調査の方向性

まず、issue にリンクされている Scala 3 の Named Tuples と Structural Types のドキュメントを読み、その後 Cats に既存する mapN API と parMapN API を探してください。issue にはファイルもテストも記載されていません。完了とするには、名前付き applicative composition のための 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時間
マージ済み PR(30日)
6

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

typelevel/cats のほかの issue

typelevel/cats の issue をすべて見る

似ている issue

Scala の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。