Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 14:20
Show Gist options
  • Save rightfold/5aeba2a4813f8427ac0a to your computer and use it in GitHub Desktop.
Save rightfold/5aeba2a4813f8427ac0a to your computer and use it in GitHub Desktop.
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)
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