5 // Zoltan Varga (vargaz@gmail.com)
6 // Marek Safar (marek.safar@gmail.com)
8 // Copyright (C) 2009 Novell
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Collections;
34 using System.Collections.Generic;
38 public partial class Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>
40 public Tuple (T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest)
52 if (!typeof (TRest).IsGenericType)
55 Type t = typeof (TRest).GetGenericTypeDefinition ();
56 if (!(t == typeof (Tuple<>) || t == typeof (Tuple<,>) || t == typeof (Tuple<,,>) || t == typeof (Tuple<,,,>) || t == typeof (Tuple<,,,,>) || t == typeof (Tuple <,,,,,>) || t == typeof (Tuple<,,,,,,>) || t == typeof (Tuple<,,,,,,,>)))
60 throw new ArgumentException ("rest", "The last element of an eight element tuple must be a Tuple.");
64 /* The rest is generated by the script at the bottom */
67 public class Tuple<T1> : IStructuralEquatable, IStructuralComparable, IComparable
71 public Tuple (T1 item1)
80 int IComparable.CompareTo (object obj)
82 return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
85 int IStructuralComparable.CompareTo (object other, IComparer comparer)
87 var t = other as Tuple<T1>;
89 if (other == null) return 1;
90 throw new ArgumentException ("other");
93 return comparer.Compare (item1, t.item1);
96 public override bool Equals (object obj)
98 return ((IStructuralEquatable) this).Equals (obj, EqualityComparer<object>.Default);
101 bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer)
103 var t = other as Tuple<T1>;
107 return comparer.Equals (item1, t.item1);
110 public override int GetHashCode ()
112 return ((IStructuralEquatable) this).GetHashCode (EqualityComparer<object>.Default);
115 int IStructuralEquatable.GetHashCode (IEqualityComparer comparer)
117 return comparer.GetHashCode (item1);
120 public override string ToString ()
122 return String.Format ("({0})", item1);
127 public class Tuple<T1, T2> : IStructuralEquatable, IStructuralComparable, IComparable
132 public Tuple (T1 item1, T2 item2)
139 get { return item1; }
143 get { return item2; }
146 int IComparable.CompareTo (object obj)
148 return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
151 int IStructuralComparable.CompareTo (object other, IComparer comparer)
153 var t = other as Tuple<T1, T2>;
155 if (other == null) return 1;
156 throw new ArgumentException ("other");
159 int res = comparer.Compare (item1, t.item1);
160 if (res != 0) return res;
161 return comparer.Compare (item2, t.item2);
164 public override bool Equals (object obj)
166 return ((IStructuralEquatable) this).Equals (obj, EqualityComparer<object>.Default);
169 bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer)
171 var t = other as Tuple<T1, T2>;
175 return comparer.Equals (item1, t.item1) &&
176 comparer.Equals (item2, t.item2);
179 public override int GetHashCode ()
181 return ((IStructuralEquatable) this).GetHashCode (EqualityComparer<object>.Default);
184 int IStructuralEquatable.GetHashCode (IEqualityComparer comparer)
186 int h = comparer.GetHashCode (item1);
187 h = (h << 5) - h + comparer.GetHashCode (item2);
191 public override string ToString ()
193 return String.Format ("({0}, {1})", item1, item2);
198 public class Tuple<T1, T2, T3> : IStructuralEquatable, IStructuralComparable, IComparable
204 public Tuple (T1 item1, T2 item2, T3 item3)
212 get { return item1; }
216 get { return item2; }
220 get { return item3; }
223 int IComparable.CompareTo (object obj)
225 return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
228 int IStructuralComparable.CompareTo (object other, IComparer comparer)
230 var t = other as Tuple<T1, T2, T3>;
232 if (other == null) return 1;
233 throw new ArgumentException ("other");
236 int res = comparer.Compare (item1, t.item1);
237 if (res != 0) return res;
238 res = comparer.Compare (item2, t.item2);
239 if (res != 0) return res;
240 return comparer.Compare (item3, t.item3);
243 public override bool Equals (object obj)
245 return ((IStructuralEquatable) this).Equals (obj, EqualityComparer<object>.Default);
248 bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer)
250 var t = other as Tuple<T1, T2, T3>;
254 return comparer.Equals (item1, t.item1) &&
255 comparer.Equals (item2, t.item2) &&
256 comparer.Equals (item3, t.item3);
259 public override int GetHashCode ()
261 return ((IStructuralEquatable) this).GetHashCode (EqualityComparer<object>.Default);
264 int IStructuralEquatable.GetHashCode (IEqualityComparer comparer)
266 int h = comparer.GetHashCode (item1);
267 h = (h << 5) - h + comparer.GetHashCode (item2);
268 h = (h << 5) - h + comparer.GetHashCode (item3);
272 public override string ToString ()
274 return String.Format ("({0}, {1}, {2})", item1, item2, item3);
279 public class Tuple<T1, T2, T3, T4> : IStructuralEquatable, IStructuralComparable, IComparable
286 public Tuple (T1 item1, T2 item2, T3 item3, T4 item4)
295 get { return item1; }
299 get { return item2; }
303 get { return item3; }
307 get { return item4; }
310 int IComparable.CompareTo (object obj)
312 return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
315 int IStructuralComparable.CompareTo (object other, IComparer comparer)
317 var t = other as Tuple<T1, T2, T3, T4>;
319 if (other == null) return 1;
320 throw new ArgumentException ("other");
323 int res = comparer.Compare (item1, t.item1);
324 if (res != 0) return res;
325 res = comparer.Compare (item2, t.item2);
326 if (res != 0) return res;
327 res = comparer.Compare (item3, t.item3);
328 if (res != 0) return res;
329 return comparer.Compare (item4, t.item4);
332 public override bool Equals (object obj)
334 return ((IStructuralEquatable) this).Equals (obj, EqualityComparer<object>.Default);
337 bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer)
339 var t = other as Tuple<T1, T2, T3, T4>;
343 return comparer.Equals (item1, t.item1) &&
344 comparer.Equals (item2, t.item2) &&
345 comparer.Equals (item3, t.item3) &&
346 comparer.Equals (item4, t.item4);
349 public override int GetHashCode ()
351 return ((IStructuralEquatable) this).GetHashCode (EqualityComparer<object>.Default);
354 int IStructuralEquatable.GetHashCode (IEqualityComparer comparer)
356 int h = comparer.GetHashCode (item1);
357 h = (h << 5) - h + comparer.GetHashCode (item2);
358 h = (h << 5) - h + comparer.GetHashCode (item3);
359 h = (h << 5) - h + comparer.GetHashCode (item4);
363 public override string ToString ()
365 return String.Format ("({0}, {1}, {2}, {3})", item1, item2, item3, item4);
370 public class Tuple<T1, T2, T3, T4, T5> : IStructuralEquatable, IStructuralComparable, IComparable
378 public Tuple (T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
388 get { return item1; }
392 get { return item2; }
396 get { return item3; }
400 get { return item4; }
404 get { return item5; }
407 int IComparable.CompareTo (object obj)
409 return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
412 int IStructuralComparable.CompareTo (object other, IComparer comparer)
414 var t = other as Tuple<T1, T2, T3, T4, T5>;
416 if (other == null) return 1;
417 throw new ArgumentException ("other");
420 int res = comparer.Compare (item1, t.item1);
421 if (res != 0) return res;
422 res = comparer.Compare (item2, t.item2);
423 if (res != 0) return res;
424 res = comparer.Compare (item3, t.item3);
425 if (res != 0) return res;
426 res = comparer.Compare (item4, t.item4);
427 if (res != 0) return res;
428 return comparer.Compare (item5, t.item5);
431 public override bool Equals (object obj)
433 return ((IStructuralEquatable) this).Equals (obj, EqualityComparer<object>.Default);
436 bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer)
438 var t = other as Tuple<T1, T2, T3, T4, T5>;
442 return comparer.Equals (item1, t.item1) &&
443 comparer.Equals (item2, t.item2) &&
444 comparer.Equals (item3, t.item3) &&
445 comparer.Equals (item4, t.item4) &&
446 comparer.Equals (item5, t.item5);
449 public override int GetHashCode ()
451 return ((IStructuralEquatable) this).GetHashCode (EqualityComparer<object>.Default);
454 int IStructuralEquatable.GetHashCode (IEqualityComparer comparer)
456 int h = comparer.GetHashCode (item1);
457 h = (h << 5) - h + comparer.GetHashCode (item2);
458 h = (h << 5) - h + comparer.GetHashCode (item3);
459 h = (h << 5) - h + comparer.GetHashCode (item4);
460 h = (h << 5) - h + comparer.GetHashCode (item5);
464 public override string ToString ()
466 return String.Format ("({0}, {1}, {2}, {3}, {4})", item1, item2, item3, item4, item5);
471 public class Tuple<T1, T2, T3, T4, T5, T6> : IStructuralEquatable, IStructuralComparable, IComparable
480 public Tuple (T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
491 get { return item1; }
495 get { return item2; }
499 get { return item3; }
503 get { return item4; }
507 get { return item5; }
511 get { return item6; }
514 int IComparable.CompareTo (object obj)
516 return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
519 int IStructuralComparable.CompareTo (object other, IComparer comparer)
521 var t = other as Tuple<T1, T2, T3, T4, T5, T6>;
523 if (other == null) return 1;
524 throw new ArgumentException ("other");
527 int res = comparer.Compare (item1, t.item1);
528 if (res != 0) return res;
529 res = comparer.Compare (item2, t.item2);
530 if (res != 0) return res;
531 res = comparer.Compare (item3, t.item3);
532 if (res != 0) return res;
533 res = comparer.Compare (item4, t.item4);
534 if (res != 0) return res;
535 res = comparer.Compare (item5, t.item5);
536 if (res != 0) return res;
537 return comparer.Compare (item6, t.item6);
540 public override bool Equals (object obj)
542 return ((IStructuralEquatable) this).Equals (obj, EqualityComparer<object>.Default);
545 bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer)
547 var t = other as Tuple<T1, T2, T3, T4, T5, T6>;
551 return comparer.Equals (item1, t.item1) &&
552 comparer.Equals (item2, t.item2) &&
553 comparer.Equals (item3, t.item3) &&
554 comparer.Equals (item4, t.item4) &&
555 comparer.Equals (item5, t.item5) &&
556 comparer.Equals (item6, t.item6);
559 public override int GetHashCode ()
561 return ((IStructuralEquatable) this).GetHashCode (EqualityComparer<object>.Default);
564 int IStructuralEquatable.GetHashCode (IEqualityComparer comparer)
566 int h = comparer.GetHashCode (item1);
567 h = (h << 5) - h + comparer.GetHashCode (item2);
568 h = (h << 5) - h + comparer.GetHashCode (item3);
569 h = (h << 5) - h + comparer.GetHashCode (item4);
570 h = (h << 5) - h + comparer.GetHashCode (item5);
571 h = (h << 5) - h + comparer.GetHashCode (item6);
575 public override string ToString ()
577 return String.Format ("({0}, {1}, {2}, {3}, {4}, {5})", item1, item2, item3, item4, item5, item6);
582 public class Tuple<T1, T2, T3, T4, T5, T6, T7> : IStructuralEquatable, IStructuralComparable, IComparable
592 public Tuple (T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
604 get { return item1; }
608 get { return item2; }
612 get { return item3; }
616 get { return item4; }
620 get { return item5; }
624 get { return item6; }
628 get { return item7; }
631 int IComparable.CompareTo (object obj)
633 return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
636 int IStructuralComparable.CompareTo (object other, IComparer comparer)
638 var t = other as Tuple<T1, T2, T3, T4, T5, T6, T7>;
640 if (other == null) return 1;
641 throw new ArgumentException ("other");
644 int res = comparer.Compare (item1, t.item1);
645 if (res != 0) return res;
646 res = comparer.Compare (item2, t.item2);
647 if (res != 0) return res;
648 res = comparer.Compare (item3, t.item3);
649 if (res != 0) return res;
650 res = comparer.Compare (item4, t.item4);
651 if (res != 0) return res;
652 res = comparer.Compare (item5, t.item5);
653 if (res != 0) return res;
654 res = comparer.Compare (item6, t.item6);
655 if (res != 0) return res;
656 return comparer.Compare (item7, t.item7);
659 public override bool Equals (object obj)
661 return ((IStructuralEquatable) this).Equals (obj, EqualityComparer<object>.Default);
664 bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer)
666 var t = other as Tuple<T1, T2, T3, T4, T5, T6, T7>;
670 return comparer.Equals (item1, t.item1) &&
671 comparer.Equals (item2, t.item2) &&
672 comparer.Equals (item3, t.item3) &&
673 comparer.Equals (item4, t.item4) &&
674 comparer.Equals (item5, t.item5) &&
675 comparer.Equals (item6, t.item6) &&
676 comparer.Equals (item7, t.item7);
679 public override int GetHashCode ()
681 return ((IStructuralEquatable) this).GetHashCode (EqualityComparer<object>.Default);
684 int IStructuralEquatable.GetHashCode (IEqualityComparer comparer)
686 int h = comparer.GetHashCode (item1);
687 h = (h << 5) - h + comparer.GetHashCode (item2);
688 h = (h << 5) - h + comparer.GetHashCode (item3);
689 h = (h << 5) - h + comparer.GetHashCode (item4);
690 h = (h << 5) - h + comparer.GetHashCode (item5);
691 h = (h << 5) - h + comparer.GetHashCode (item6);
692 h = (h << 5) - h + comparer.GetHashCode (item7);
696 public override string ToString ()
698 return String.Format ("({0}, {1}, {2}, {3}, {4}, {5}, {6})", item1, item2, item3, item4, item5, item6, item7);
703 public partial class Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> : IStructuralEquatable, IStructuralComparable, IComparable
715 get { return item1; }
719 get { return item2; }
723 get { return item3; }
727 get { return item4; }
731 get { return item5; }
735 get { return item6; }
739 get { return item7; }
746 int IComparable.CompareTo (object obj)
748 return ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);
751 int IStructuralComparable.CompareTo (object other, IComparer comparer)
753 var t = other as Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>;
755 if (other == null) return 1;
756 throw new ArgumentException ("other");
759 int res = comparer.Compare (item1, t.item1);
760 if (res != 0) return res;
761 res = comparer.Compare (item2, t.item2);
762 if (res != 0) return res;
763 res = comparer.Compare (item3, t.item3);
764 if (res != 0) return res;
765 res = comparer.Compare (item4, t.item4);
766 if (res != 0) return res;
767 res = comparer.Compare (item5, t.item5);
768 if (res != 0) return res;
769 res = comparer.Compare (item6, t.item6);
770 if (res != 0) return res;
771 res = comparer.Compare (item7, t.item7);
772 if (res != 0) return res;
773 return comparer.Compare (rest, t.rest);
776 public override bool Equals (object obj)
778 return ((IStructuralEquatable) this).Equals (obj, EqualityComparer<object>.Default);
781 bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer)
783 var t = other as Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>;
787 return comparer.Equals (item1, t.item1) &&
788 comparer.Equals (item2, t.item2) &&
789 comparer.Equals (item3, t.item3) &&
790 comparer.Equals (item4, t.item4) &&
791 comparer.Equals (item5, t.item5) &&
792 comparer.Equals (item6, t.item6) &&
793 comparer.Equals (item7, t.item7) &&
794 comparer.Equals (rest, t.rest);
797 public override int GetHashCode ()
799 return ((IStructuralEquatable) this).GetHashCode (EqualityComparer<object>.Default);
802 int IStructuralEquatable.GetHashCode (IEqualityComparer comparer)
804 int h = comparer.GetHashCode (item1);
805 h = (h << 5) - h + comparer.GetHashCode (item2);
806 h = (h << 5) - h + comparer.GetHashCode (item3);
807 h = (h << 5) - h + comparer.GetHashCode (item4);
808 h = (h << 5) - h + comparer.GetHashCode (item5);
809 h = (h << 5) - h + comparer.GetHashCode (item6);
810 h = (h << 5) - h + comparer.GetHashCode (item7);
811 h = (h << 5) - h + comparer.GetHashCode (rest);
815 public override string ToString ()
817 return String.Format ("({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7})", item1, item2, item3, item4, item5, item6, item7, rest);
834 public class TupleGen
836 public static void Main () {
837 for (int arity = 1; arity < 9; ++arity) {
838 string type_name = GetTypeName (arity);
840 Console.WriteLine ("\t[Serializable]");
841 Console.Write ("\tpublic {0}class ", arity < 8 ? null : "partial ");
842 Console.Write (type_name);
843 Console.WriteLine (" : IStructuralEquatable, IStructuralComparable, IComparable");
844 Console.WriteLine ("\t{");
845 for (int i = 1; i <= arity; ++i)
846 Console.WriteLine ("\t\t{0} {1};", GetItemTypeName (i), GetItemName (i));
849 Console.WriteLine ();
850 Console.Write ("\t\tpublic Tuple (");
851 for (int i = 1; i <= arity; ++i) {
852 Console.Write ("{0} {1}", GetItemTypeName (i), GetItemName (i));
854 Console.Write (", ");
856 Console.WriteLine (")");
857 Console.WriteLine ("\t\t{");
858 for (int i = 1; i <= arity; ++i)
859 Console.WriteLine ("\t\t\t this.{0} = {0};", GetItemName (i));
860 Console.WriteLine ("\t\t}");
863 for (int i = 1; i <= arity; ++i) {
864 Console.WriteLine ();
865 Console.WriteLine ("\t\tpublic {0} {1} {{", GetItemTypeName (i),
866 System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToTitleCase (GetItemName (i)));
867 Console.Write ("\t\t\tget { ");
868 Console.WriteLine ("return {0}; }}", GetItemName (i));
869 Console.WriteLine ("\t\t}");
872 Console.WriteLine ();
873 Console.WriteLine ("\t\tint IComparable.CompareTo (object obj)");
874 Console.WriteLine ("\t\t{");
875 Console.WriteLine ("\t\t\treturn ((IStructuralComparable) this).CompareTo (obj, Comparer<object>.Default);");
876 Console.WriteLine ("\t\t}");
878 Console.WriteLine ();
879 Console.WriteLine ("\t\tint IStructuralComparable.CompareTo (object other, IComparer comparer)");
880 Console.WriteLine ("\t\t{");
881 Console.WriteLine ("\t\t\tvar t = other as {0};", type_name);
882 Console.WriteLine ("\t\t\tif (t == null) {");
883 Console.WriteLine ("\t\t\t\tif (other == null) return 1;");
884 Console.WriteLine ("\t\t\t\tthrow new ArgumentException ("other");");
885 Console.WriteLine ("\t\t\t}");
886 Console.WriteLine ();
888 for (int i = 1; i < arity; ++i) {
889 Console.Write ("\t\t\t");
891 Console.Write ("int ");
893 Console.WriteLine ("res = comparer.Compare ({0}, t.{0});", GetItemName (i));
894 Console.WriteLine ("\t\t\tif (res != 0) return res;");
896 Console.WriteLine ("\t\t\treturn comparer.Compare ({0}, t.{0});", GetItemName (arity));
897 Console.WriteLine ("\t\t}");
899 Console.WriteLine ();
900 Console.WriteLine ("\t\tpublic override bool Equals (object obj)");
901 Console.WriteLine ("\t\t{");
902 Console.WriteLine ("\t\t\treturn ((IStructuralEquatable) this).Equals (obj, EqualityComparer<object>.Default);");
903 Console.WriteLine ("\t\t}");
905 Console.WriteLine ();
906 Console.WriteLine ("\t\tbool IStructuralEquatable.Equals (object other, IEqualityComparer comparer)");
907 Console.WriteLine ("\t\t{");
908 Console.WriteLine ("\t\t\tvar t = other as {0};", type_name);
909 Console.WriteLine ("\t\t\tif (t == null)");
910 Console.WriteLine ("\t\t\t\treturn false;");
911 Console.WriteLine ();
912 Console.Write ("\t\t\treturn");
914 for (int i = 1; i <= arity; ++i) {
918 Console.Write ("\t\t\t\t");
920 Console.Write ("comparer.Equals ({0}, t.{0})", GetItemName (i));
922 Console.WriteLine (" &&");
924 Console.WriteLine (";");
926 Console.WriteLine ("\t\t}");
928 Console.WriteLine ();
929 Console.WriteLine ("\t\tpublic override int GetHashCode ()");
930 Console.WriteLine ("\t\t{");
931 Console.WriteLine ("\t\t\treturn ((IStructuralEquatable) this).GetHashCode (EqualityComparer<object>.Default);");
932 Console.WriteLine ("\t\t}");
934 Console.WriteLine ();
935 Console.WriteLine ("\t\tint IStructuralEquatable.GetHashCode (IEqualityComparer comparer)");
936 Console.WriteLine ("\t\t{");
938 Console.WriteLine ("\t\t\treturn comparer.GetHashCode ({0});", GetItemName (arity));
940 Console.WriteLine ("\t\t\tint h = comparer.GetHashCode ({0});", GetItemName (1));
941 for (int i = 2; i <= arity; ++i)
942 Console.WriteLine ("\t\t\th = (h << 5) - h + comparer.GetHashCode ({0});", GetItemName (i));
943 Console.WriteLine ("\t\t\treturn h;");
946 Console.WriteLine ("\t\t}");
948 Console.WriteLine ();
949 Console.WriteLine ("\t\tpublic override string ToString ()");
950 Console.WriteLine ("\t\t{");
951 Console.Write ("\t\t\treturn String.Format (\"(");
952 for (int i = 1; i <= arity; ++i) {
953 Console.Write ("{" + (i - 1) + "}");
955 Console.Write (", ");
957 Console.Write (")\", ");
958 for (int i = 1; i <= arity; ++i) {
959 Console.Write (GetItemName (i));
961 Console.Write (", ");
963 Console.WriteLine (");");
964 Console.WriteLine ("\t\t}");
966 Console.WriteLine ("\t}\n");
970 static string GetTypeName (int arity)
972 StringBuilder sb = new StringBuilder ();
973 sb.Append ("Tuple<");
974 for (int i = 1; i <= arity; ++i) {
975 sb.Append (GetItemTypeName (i));
981 return sb.ToString ();
984 static string GetItemName (int arity)
986 return arity < 8 ? "item" + arity.ToString () : "rest";
989 static string GetItemTypeName (int arity)
991 return arity < 8 ? "T" + arity.ToString () : "TRest";