Skip to content

Instantly share code, notes, and snippets.

@bromne
Created October 26, 2017 06:18
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 bromne/9cc125bb1389f1b459a6c4a040b66ad0 to your computer and use it in GitHub Desktop.
Save bromne/9cc125bb1389f1b459a6c4a040b66ad0 to your computer and use it in GitHub Desktop.
帰納的可変長多相型(recursive variable-length polymorphic type)
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