Inheritance is bad you say? I bet your "Haskell" can't do this!
sealed trait Integer
sealed trait Nat extends Integer
case object Zero extends Nat
case class Succ(pred: Nat) extends Nat
case class Negate(nonzero: Succ) extends Integer
Conversation
Replying to
Is this inheritance or just subtyping though? I sometimes get confused at the difference.
I guess it's inheritance because you are pulling the constructors from the supertype, right?
1
Granted, Haskellers are weird when it comes to subtyping too though.
1
2
Show replies

