Forked from johnynek/dependent_type_question.scala
Last active
August 29, 2015 14:11
-
-
Save travisbrown/cdd878f7739ab34ce079 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 trait Key { | |
type Inner | |
def inner: Inner | |
} | |
trait IntKey extends Key { | |
type Inner = Int | |
} | |
trait StringKey extends Key { | |
type Inner = String | |
} | |
object Key { | |
def work(m: Key): m.Inner = m match { | |
case i: IntKey => i.inner | |
case s: StringKey => s.inner | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pretty neat compiler error message: