Idea: Polymorphism for the compiler plugin
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by reviewing the compiler plugin behavior described here and compare it with issue #1347 and the linked kotlin-structural-typing project. Define how a final local DataFrame type should gain compatible @DataSchema interfaces within its module, then verify the UserLike example compiles and supports the nameAndAge call.
索引モデルが issue の本文から書いたものです。
説明
Similar yet alternative approach to https://github.com/Kotlin/dataframe/issues/1347. Can we use the compiler plugin to write code like this?
@DataSchema
interface UserLike {
val name: String
val age: Int
}
fun DataFrame<UserLike>.nameAndAge(): String = rows().joinToString { "$name is $age years old" }
fun main() {
val df = dataFrameOf(
"name" to columnOf("Alice", "John"),
"age" to columnOf(12, 13),
"favoriteColor" to columnOf("blue", "yellow"),
)
println(df.nameAndAge())
}
In this example, val df: DataFrame<DataFrameOf_41>, DataFrameOf_41 would automatically gain UserLike as supertype because it is compatible.
Background
I was inspired by https://github.com/obabichev/kotlin-structural-typing, a compiler plugin that allows writing code like this:
You can see, it automatically injects @Structural interfaces as supertype of classes if they are compatible. This allows you to write a function like
fun UserLike.nameAndAge(): String = "$name is $age years old"
and you can call it on both users and dogs.
This logic also works with dataframe and the compiler plugin, as long as you materialize the schema and cast to it:
Of course, what would be the most useful is if our local types automatically pick up compatible @DataSchema interfaces as supertype! That would make dataframes polymorphic again :)
We can save us a combinatorial explosion by only adding supertypes to the final local type, not intermediate interfaces and by sticking to the module it's written in, similar to the @Structural plugin.
Overlap with https://github.com/Kotlin/dataframe/issues/1347
While there is overlap, this idea is simpler and more concrete. It doesn't use generics and requires no tracking of a modifying data schema. Of course #1347 would be even better, but it is likely outside the 1.0 scope. This idea might be small enough to be included, maybe.
- 主要言語
- Kotlin
- スター
- 1.1k
- フォーク
- 87
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 40
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Kotlin/dataframe のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
API
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Kotlin/dataframe#2202 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Kotlin/dataframe#2195 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
AX
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
Add minimal KDocs for `print` APIs対応中かも @zaleslaw が 4 日前に担当しました。 オープンKDocs
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
Kotlin/dataframe の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
OneBusAway/vehicle-positions#288 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
[New Rule]zstd-kmpオープン
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
LibChecker/LibChecker-Rules#1456 ·
-
支持iOS 15.1及以上的系统オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信