Skip to content

Instantly share code, notes, and snippets.

@halcat0x15a
Created July 19, 2011 14:57
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 halcat0x15a/1092653 to your computer and use it in GitHub Desktop.
Save halcat0x15a/1092653 to your computer and use it in GitHub Desktop.
型のリストでゴニョゴニョ
trait AbstractList
trait Cons[X, XS <: AbstractList] extends AbstractList
trait Nil extends AbstractList
type TypeList = List[Manifest[_]]
def typeList[A <: AbstractList: Manifest]: TypeList = {
lazy val typeList: PartialFunction[TypeList, TypeList] = {
case x :: xs => x :: typeList(xs.head.typeArguments)
case _ => scala.Nil
}
typeList(manifest[A].typeArguments)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment