Skip to content

Instantly share code, notes, and snippets.

@loverdos
Created January 28, 2015 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loverdos/2c4310569685b4e708e8 to your computer and use it in GitHub Desktop.
Save loverdos/2c4310569685b4e708e8 to your computer and use it in GitHub Desktop.
trait TypeContainer {
type A
type B
type ABPlus
type C
}
trait TypeProjector[TC <: TypeContainer] {
type A = TC#A
type B = TC#B
type ABPlus = TC#ABPlus
type C = TC#C
}
trait API[TC <: TypeContainer] extends TypeProjector[TC] {
def addAB(a: A, b: B): ABPlus
}
class FirstContainer extends TypeContainer {
type A = String
type B = Int
type ABPlus = String
type C = Boolean
}
class FirstAPI extends API[FirstContainer] {
def addAB(a: String, b: Int): String = a + b
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment