scala-with-cats icon indicating copy to clipboard operation
scala-with-cats copied to clipboard

trait

Open kun-song opened this issue 6 years ago • 0 comments

As we said in Essential Scala, there are two functional programming patterns that we should consider when defining a trait:

  • we can make it a typeclass, or;
  • we can make it an algebraic data type (and hence seal it).

Type classes allow us to unify disparate data types with a common interface. This doesn’t seem like what we’re trying to do here. That leaves us with an algebraic data type. Let’s keep that thought in mind as we explore the design a bit further.

kun-song avatar Mar 28 '18 14:03 kun-song