ঢ়ଶΛྻڍܕͰදݱ͢Δ
sealed trait State
object State {
case object Requested extends State
case object Paid extends State
case object Failed extends State
}
※࣮ࡍ͏ͪΐͬͱ͍Ζ͍Ζ͋Γ·͢
Slide 35
Slide 35 text
ঢ়ଶΛྻڍܕͰදݱ͢Δ
case class Payment(state: State) {
def charged: Boolean = state match {
case State.Paid => true
case _ => false
}
}
ίʔυྫ
case class EntityKey[ID](
val repr: String
) extends AnyVal
abstract class Entity[K, +V](
val id: EntityKey[K],
val value: V
)(implicit ev: V <:< K)
Slide 59
Slide 59 text
ίʔυྫ
case class EntityKey[ID](
val repr: String
) extends AnyVal
abstract class Entity[K, +V](
val id: EntityKey[K],
val value: V
)(implicit ev: V <:< K)
phantom type
Slide 60
Slide 60 text
ίʔυྫ
case class EntityKey[ID](
val repr: String
) extends AnyVal
abstract class Entity[K, +V](
val id: EntityKey[K],
val value: V
)(implicit ev: V <:< K)
ܕΛڞมʹ
Slide 61
Slide 61 text
ίʔυྫ
case class EntityKey[ID](
val repr: String
) extends AnyVal
abstract class Entity[K, +V](
val id: EntityKey[K],
val value: V
)(implicit ev: V <:< K)
ͷܕ͕IDͷܕͷαϒΫϥεͰ͋Δ
ܕύϥϝʔλ੍