Scala には暗黙の型変換機能がある。 例を挙げてみよう。 abstract class Monoid[A] { def add(x: A, y: A): A def unit: A } Monoid クラスは、二つの機能を持つ。 add 関数により、二つの値を足し合わせた値を返す unit は値の空値を返す [A] の部分が Generics になっていて、任意の型に適用することができる。 以下が String 版 Monoid。 object stringMonoid extends Monoid[String] { def add(x: String, y: String): String = x.concat(y) def unit: String = "" } 以下が Int 版 Monoid。 object intMonoid extends Monoid[Int] { de