Created
March 12, 2011 09:16
-
-
Save retronym/867149 to your computer and use it in GitHub Desktop.
Passing a list of types to a Scala annotation
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
import TList._ | |
class sealedd[TS <: TL[_ <: Singleton]] extends Annotation | |
object test { | |
@sealedd[Value.A.type :: Value.B.type :: TNil[_ <: Singleton]] | |
trait Value | |
object Value { | |
object A extends Value | |
object B extends Value | |
} | |
} | |
// Borrowed from https://github.com/harrah/up/blob/master/TList.scala | |
sealed trait TList { | |
type Head <: Value | |
type Tail <: TL[Value] | |
type Value | |
} | |
sealed trait TCons[H <: T#Value, T <: TList] extends TList { | |
type Head = H | |
type Tail = T | |
type Value = T#Value | |
} | |
sealed trait TNil[V] extends TList { | |
type Head = Nothing | |
type Tail = Nothing | |
type Value = V | |
} | |
object TList { | |
type ::[H <: T#Value, T <: TList] = TCons[H, T] | |
type TL[V] = TList { type Value <: V } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment