-
-
Save rightfold/5aeba2a4813f8427ac0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed abstract class Kind { | |
def isCustomer = this.isInstanceOf[CustomerKind] | |
def isProspect = this.isInstanceOf[ProspectKind] | |
def isSupplier = this.isInstanceOf[SupplierKind] | |
} | |
sealed trait CustomerKind { this: AcquaintanceKind => } | |
sealed trait ProspectKind { this: AcquaintanceKind => } | |
sealed trait SupplierKind { this: AcquaintanceKind => } | |
type Customer = Kind with CustomerKind | |
type Prospect = Kind with ProspectKind | |
type Supplier = Kind with SupplierKind | |
type CustomerSupplier = Customer with Supplier | |
type ProspectSupplier = Prospect with Supplier | |
val Customer = new Customer | |
val Prospect = new Prospect | |
val Supplier = new Supplier | |
val CustomerSupplier = new CustomerSupplier | |
val ProspectSupplier = new ProspectSupplier | |
case class Acquaintance[+K <: Kind](id: UUID, name: String, kind: K) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main extends App { | |
val a = new Acquaintance[CustomerSupplier](UUID.v4, "x", CustomerSupplier) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment