Created
January 28, 2015 16:53
-
-
Save loverdos/2c4310569685b4e708e8 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
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