Created
October 26, 2017 06:18
-
-
Save bromne/9cc125bb1389f1b459a6c4a040b66ad0 to your computer and use it in GitHub Desktop.
帰納的可変長多相型(recursive variable-length polymorphic type)
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
class Router<T...> { | |
portions: [String]; | |
when (T) { | |
case <>: { | |
} | |
otherwise: { | |
leading: Router<* T.init>; | |
parser: Parser<T.last>; | |
} | |
} | |
} | |
// 出力 | |
class Router0 { | |
portions: [String]; | |
} | |
class Router1<T1> { | |
leading: Router0; | |
parser: Parser<T1>; | |
portions: [String]; | |
} | |
class Router2<T1, T2> { | |
leading: Router1<T1>; | |
parser: Parser<T2>; | |
portions: [String]; | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment