[generics-rep] Newtypes for deriving via
まだ誰も着手していません。
- #37 @kl0tl による — マージされずにクローズ
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 20/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 領域
- backend
調査の方向性
Read the issue’s deriving-via examples and the linked PureScript PR #3824 to understand the proposed mechanism. The issue asks for naming guidance for newtypes such as GenericBounded, GenericShow, and GenericEnum; done would mean a naming scheme is agreed on, but the thread has no recorded decision and a linked pull request is closed.
索引モデルが issue の本文から書いたものです。
説明
With deriving via and some newtypes we could simulate defaults methods and alleviate a bit the implementation of typeclasses with generic defaults.
For instance implementing Show, Enum and Bounded:
module Example where
import Data.Enum (class Enum)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Bounded (genericBottom, genericTop)
import Data.Generic.Rep.Enum (genericSucc, genericPred)
import Data.Generic.Rep.Show (genericShow)
data ABC = A | B | C
derive instance eqABC :: Eq ABC
derive instance ordABC :: Ord ABC
derive instance genericABC :: Generic ABC _
instance showABC :: Show ABC where
show = genericShow
instance boundedABC :: Bounded ABC where
top = genericTop
bottom = genericBottom
instance enumABC :: Enum ABC where
succ = genericSucc
pred = genericPred
Could be a bit more compact:
module Example where
import Data.Enum (class Enum)
import Data.Generic.Rep (class Generic)
-import Data.Generic.Rep.Bounded (genericBottom, genericTop)
+import Data.Generic.Rep.Bounded (GenericBounded)
-import Data.Generic.Rep.Enum (genericSucc, genericPred)
+import Data.Generic.Rep.Enum (GenericEnum)
-import Data.Generic.Rep.Show (genericShow)
+import Data.Generic.Rep.Show (GenericShow)
data ABC = A | B | C
derive instance eqABC :: Eq ABC
derive instance ordABC :: Ord ABC
derive instance genericABC :: Generic ABC _
+derive via (GenericShow ABC) instance showABC :: Show ABC
-instance showABC :: Show ABC where
- show = genericShow
+derive via (GenericBounded ABC) instance boundedABC :: Bounded ABC
-instance boundedABC :: Bounded ABC where
- top = genericTop
- bottom = genericBottom
+derive via (GenericEnum ABC) instance enumABC :: Enum ABC
-instance enumABC :: Enum ABC where
- succ = genericSucc
- pred = genericPred
Writing those newtypes is straightforward and I gladly volonteer. The only annoyance is how to name them: GenericBounded isn’t taken but GenericShow and GenericEnum refer to the typeclasses implemented by the generic representation.
Would it be acceptable to rename the typeclasses to GenericRep* and keep Generic* for the newtypes? Or has someone a better naming scheme to propose?
- 主要言語
- PureScript
- スター
- 168
- フォーク
- 90
- 平均マージ
- 3日 1時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
purescript/purescript-prelude のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 57/100
purescript/purescript-prelude#317 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 32/100
purescript/purescript-prelude#312 · コメント 5 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
purescript/purescript-prelude#310 · コメント 5 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 24/100
purescript/purescript-prelude#308 · コメント 2 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
purescript/purescript-prelude#307 · コメント 1 件 · リアクション 1 件 ·
purescript/purescript-prelude の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
ManageSieve proxy: a backend's NO/BYE greeting is skipped as a capability line and reported as EOFオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ManageIQ/manageiq-pods#1476 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
prime-radiant-inc/evener#6366 ·
メンテナーはふだん 1 日以内に返信