Haskell平等 - 差异?

时间:2015-04-03 18:35:42

标签: haskell scalaz

learning Scalaz展示了如何在Haskell和scalaz中创建代数数据类型:

data TrafficLight = Red | Yellow | Green deriving Eq

sealed trait TrafficLight
case object Red    extends TrafficLight
case object Yellow extends TrafficLight
case object Green  extends TrafficLight

但是,正如教程所解释的那样,Equal.scala 不变

Haskell有差异吗?如果是/否,在将RedYellow进行比较时是否起作用?

Prelude> Red == Red
True
Prelude> Red == Yellow
False

0 个答案:

没有答案