"なぜshapelessにはGeneric[Boolean]がないの?"と尋ねてみた
Gitterで質問したのでそのメモ*1。 なお私の英語は壊滅的なので片言?なのは許してください。
Hello. Why does Generic[Boolean] instance not exist?
と投稿したところ、milessabinさん(shapeless作者)から
Because there's no obvious sum of product representation of Boolean. I guess you would want false.type :+: true.type :+: CNil?
と返答があった。なるほど。
@milessabin Thank you. I understand. I try to port from Haskell code(using GHC.Generic) to Scala code. GHC.Generics derive some instances of Generic a.
とりあえずこういうことしようとしたんだよーと言ったところ
@pocketberserker gotcha. The idiom here is to hand-write instances for primitives and use Generic for ADTs. I would be very interested to see a side-by-side comparison of something written with GHC generics and something written with shapeless. Would you be able to blog about it?
ほえーと思ってたらなんか後日記事かくことになった。
まぁ、最初から無理っていうのもなんだし、やるだけやってみよう…。
*1:という名のバックアップ