magnoliaというScalaの型クラスのインスタンス自動生成ライブラリの話

0
Kenji Yoshida @xuwei_k

scalaprops-magnolia 0.1.0 released 🎉 github.com/scalaprops/sca… Generation of arbitrary case classes / ADTs instances with Scalaprops and Magnolia! /cc @propensive

2018-03-17 18:02:00
Kenji Yoshida @xuwei_k

blog書きました xuwei-k.hatenablog.com/entry/2018/03/… "scalaprops-magnoliaというライブラリを作った"

2018-03-17 23:22:16
Kenji Yoshida @xuwei_k

scalaprops-magnolia で Gen[Tree[Int]] 生成すると以下のように微妙に偏るな 1. 必ず左右対称なTreeになる 2. Treeのvalueが全部同じ これどうするといい感じになるのだろうか pic.twitter.com/vvG2Ov6a8n

2018-03-18 01:01:04
拡大
Kenji Yoshida @xuwei_k

あれっ、 scalaprops-magnolia の前に scalaz-magnolia は誰か作ってないのだろうか?まだ誰も作ってないなら作るか?

2018-03-18 18:14:43
Kenji Yoshida @xuwei_k

msgpack4z-magnoliaが大体できたが、jsonと同じように sealed trait A case class B(x: Int) extends A case class C(x: Int) extends A という場合BとCの区別つけるために何かメタ情報埋め込むか、そのように衝突する場合はコンパイルエラーにする、など実装方法の選択肢が複数あり面倒になってきた

2018-03-19 12:37:12
Kenji Yoshida @xuwei_k

そしてある程度同じ役割(?)をするshapelessのやつが、いつの間にか消されていたので github.com/typelevel/shap… 余裕があったらその部分だけ自分の別リポジトリで復活させるなどするか・・・(今のところ余裕がそんなにない) せっかくだしscalaz-magnolia先に作ってみている(EqualとOrderだけ出来た)

2018-03-25 22:05:56
Kenji Yoshida @xuwei_k

Semigroup や Monoid も出来てきたけれど、これもし magnolia 自体が * な kind のものしかだめで Functor などの *->* が不可能だとしたら、そのあたり作ったらあまりやることないのでは…? ( *->* が可能か調べてない)

2018-03-25 23:35:21
FP for Mortals @fpmortals

@xuwei_k scalaz-deriving does Equal and Show already, and will do more including HKTs. Give me a few months and a poking stick for @andygscott . A magnolia deriver would be good too. I will have a chapter comparing deriving / magnolia / shapeless / macros in my book. // @propensive

2018-03-26 08:08:13
Jon Pretty @propensive

@fommil @xuwei_k @andygscott When is your publish date? I need a deadline! Would you like the "Magnolia doesn't do HKTs" claim to be out of date before or after you publish? ;)

2018-03-26 08:17:23
FP for Mortals @fpmortals

@propensive @xuwei_k @andygscott hmm. I see an opportunity to game the system. Magnolia doesn't make my breakfast for me, it sucks!

2018-03-26 08:20:04