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

Feature request: support sum type in macwire.

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

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

評価

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

調査の方向性

まず wire[...] のエントリーポイントと MainAppInjected の例を追跡し、現在どのように依存関係が解決されているかを理解します。sum-type または環境バインディングをどのように表現・合成するかを定義し、要求されている Scala 3 の使用パターンがコンパイルでき、示されている依存関係グラフをサポートすることを確認します。

索引モデルが issue の本文から書いたものです。

説明

enhancement Scala3

As the code show in gitter

trait DesuConfigModel:
  val configIO: IO[DesuConfig] = ???
end DesuConfigModel

trait AppConfig(config: DesuConfig):
end AppConfig

trait DoobieDB(config: DesuConfig):
  private val dsConfigIO = IO(config.mysqlDesuQuillDB.dataSource)
  val transactor: Resource[IO, HikariTransactor[IO]] = ???
end DoobieDB

trait FileFinder(appConfig: AppConfig, xa: Transactor[IO]):
  // code
end FileFinder

trait AppRoutes(fileFinder: FileFinder, appConfig: AppConfig):
  // code
end AppRoutes

val configModel = wire[DesuConfigModel]
val appRoutes: Resource[IO, AppRoutes] = for
  desuConfig  <- Resource.eval(configModel.configIO)
  appConfig    = wire[AppConfig]
  doobieDB     = wire[DoobieDB]
  xa                <- doobieDB.transactor
yield
  val fileFinder = wire[FileFinder]
  wire[AppRoutes]

Macwire can support wire in F[_] like distage. Since implicit value and constructor value is fetched by type. You can declare a implicit value like

implicit val implicitVarName = constructorVarName

Here request a feature that support sum type in macwire like zio.ZEnvironment. Then we can support something like distage's Module include(simple version) in Scala2 and Scala3.(distage doc)

Here is the code also in gitter

class DesuConfigModelImpl extends DesuConfigModel

class AppConfigImpl(using DesuConfig) extends AppConfig(summon)

class DoobieDBImpl(using DesuConfig) extends DoobieDB(summon)

class FileFinderImpl(using AppConfig, Transactor[IO]) extends FileFinder(summon, summon)

class AppRoutesImpl(using FileFinder, AppConfig) extends AppRoutes(summon, summon)

import zio.{IO as _, *}

object MainAppInjected:

  type ProjectEnvModule1 = DesuConfig & AppConfig & Transactor[IO]

  given [T: Tag, S <: T](using ZEnvironment[S]): T = summon[ZEnvironment[S]].get

  val envResource: Resource[IO, ZEnvironment[ProjectEnvModule1]] = for
    given DesuConfig     <- Resource.eval((new DesuConfigModelImpl).configIO)
    given AppConfig       = new AppConfigImpl
    doobieDB                 = new DoobieDBImpl
    given Transactor[IO] <- doobieDB.transactor
  yield ZEnvironment(implicitly[DesuConfig], implicitly[Transactor[IO]], implicitly[AppConfig])

  val appRoutes: Resource[IO, AppRoutes] = for
    given ZEnvironment[ProjectEnvModule1] <- envResource // distage include(simple version)
  yield
    given FileFinder = new FileFinderImpl
    new AppRoutesImpl

end MainAppInjected

It circuitously performs the macwire function I imagined use Scala3 and zio.ZEnvironment.

主要言語
Scala
スター
1.3k
フォーク
77
平均マージ
21時間 6分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

softwaremill/macwire のほかの issue

softwaremill/macwire の issue をすべて見る

似ている issue

Scala の issue をもっと見る

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

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