Permalink
Browse files

deprecate Pair and Triple

  • Loading branch information...
1 parent c243435 commit b004c3ddb38f8e690a0895a51ad0c83ff57a01e7 @densh densh committed Nov 13, 2013
Showing with 468 additions and 462 deletions.
  1. +1 −1 docs/examples/fors.scala
  2. +2 −2 docs/examples/iterators.scala
  3. +4 −4 docs/examples/jolib/Ref.scala
  4. +11 −11 docs/examples/jolib/parallelOr.scala
  5. +9 −9 docs/examples/monads/callccInterpreter.scala
  6. +7 −7 docs/examples/monads/directInterpreter.scala
  7. +5 −5 docs/examples/monads/errorInterpreter.scala
  8. +7 −7 docs/examples/monads/simpleInterpreter.scala
  9. +12 −12 docs/examples/monads/stateInterpreter.scala
  10. +4 −4 docs/examples/patterns.scala
  11. +4 −4 docs/examples/pilib/elasticBuffer.scala
  12. +19 −19 docs/examples/pilib/handover.scala
  13. +8 −8 docs/examples/pilib/piNat.scala
  14. +25 −25 docs/examples/typeinf.scala
  15. +7 −7 src/actors/scala/actors/Future.scala
  16. +4 −4 src/actors/scala/actors/remote/NetKernel.scala
  17. +2 −2 src/actors/scala/actors/remote/Proxy.scala
  18. +2 −2 src/actors/scala/actors/remote/RemoteActor.scala
  19. +4 −4 src/actors/scala/actors/remote/TcpService.scala
  20. +2 −2 src/compiler/scala/tools/ant/ScalaTool.scala
  21. +1 −1 src/compiler/scala/tools/ant/sabbus/Compilers.scala
  22. +1 −1 src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
  23. +1 −1 src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
  24. +4 −4 src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
  25. +2 −2 src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
  26. +1 −1 src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
  27. +2 −2 src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
  28. +10 −10 src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
  29. +3 −3 src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
  30. +1 −1 src/compiler/scala/tools/nsc/plugins/Plugin.scala
  31. +4 −2 src/library/scala/Predef.scala
  32. +1 −1 src/repl/scala/tools/nsc/interpreter/JavapClass.scala
  33. +3 −3 src/scaladoc/scala/tools/ant/Scaladoc.scala
  34. +3 −3 src/scalap/scala/tools/scalap/Arguments.scala
  35. +8 −8 test/disabled/run/lisp.scala
  36. +1 −1 test/files/jvm/typerep.scala
  37. +2 −2 test/files/neg/patmatexhaust.scala
  38. +1 −1 test/files/neg/t414.scala
  39. +1 −1 test/files/neg/t5702-neg-bad-and-wild.check
  40. +1 −1 test/files/neg/t5702-neg-bad-and-wild.scala
  41. +1 −1 test/files/neg/t997.scala
  42. +2 −2 test/files/neg/wellkinded_wrongarity.check
  43. +1 −1 test/files/neg/wellkinded_wrongarity.scala
  44. +3 −3 test/files/pos/bounds.scala
  45. +2 −2 test/files/pos/patmat.scala
  46. +3 −3 test/files/pos/spec-doubledef-new.scala
  47. +3 −3 test/files/pos/spec-doubledef-old.scala
  48. +1 −1 test/files/pos/t0064.scala
  49. +2 −2 test/files/pos/t247.scala
  50. +4 −4 test/files/pos/t443.scala
  51. +6 −6 test/files/pos/t4579.scala
  52. +2 −2 test/files/pos/t5120.scala
  53. +2 −2 test/files/pos/tcpoly_bounds1.scala
  54. +1 −1 test/files/pos/typealiases.scala
  55. +1 −1 test/files/pos/unapplyNeedsMemberType.scala
  56. +1 −1 test/files/pos/valdefs.scala
  57. +1 −1 test/files/positions/ExcludedPrefix1.scala
  58. +1 −1 test/files/positions/Overlap4.scala
  59. +1 −1 test/files/positions/Scaladoc7.scala
  60. +4 −4 test/files/presentation/callcc-interpreter.check
  61. +18 −14 test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala
  62. +8 −8 test/files/run/Course-2002-05.scala
  63. +1 −1 test/files/run/Course-2002-06.scala
  64. +70 −70 test/files/run/Course-2002-07.scala
  65. +14 −14 test/files/run/Course-2002-08.scala
  66. +20 −20 test/files/run/Course-2002-09.scala
  67. +8 −8 test/files/run/Course-2002-13.scala
  68. +1 −1 test/files/run/bugs.scala
  69. +1 −1 test/files/run/map_test.scala
  70. +14 −14 test/files/run/patmatnew.scala
  71. +1 −1 test/files/run/t3888.scala
  72. +1 −1 test/files/run/tailcalls.scala
  73. +2 −2 test/files/run/tcpoly_parseridioms.check
  74. +4 −4 test/files/run/tcpoly_parseridioms.scala
  75. +1 −1 test/files/run/withIndex.scala
  76. +6 −6 test/pending/run/reify_callccinterpreter.scala
  77. +5 −5 test/pending/run/reify_simpleinterpreter.scala
  78. +32 −32 test/pending/shootout/fasta.scala
  79. +9 −9 test/pending/shootout/revcomp.scala-2.scala
  80. +20 −20 test/pending/shootout/revcomp.scala-3.scala
View
@@ -83,7 +83,7 @@ object fors {
if b1 != b2;
Elem(_, "author", _, _, Text(a1)) <- b1.toList;
Elem(_, "author", _, _, Text(a2)) <- b2.toList;
- if a1 == a2) yield Pair(a1, a2))
+ if a1 == a2) yield (a1, a2))
def removeDuplicates[a](xs: List[a]): List[a] =
if (xs.isEmpty)
@@ -15,8 +15,8 @@ object iterators {
def findGreater(xs: Array[Double], limit: Double) =
xs.iterator
.zip(Iterator.from(0))
- .filter{case Pair(x, i) => x > limit }
- .map{case Pair(x, i) => i}
+ .filter{case (x, i) => x > limit }
+ .map{case (x, i) => i}
def main(args: Array[String]) {
val ar = Array/*[Double]*/(6, 2, 8, 5, 1)
@@ -12,20 +12,20 @@ import concurrent.SyncVar;
import concurrent.jolib._;
class Ref[a](init: a) extends Join {
-
+
object get extends Synchr[a](this) { case class C() extends SyncVar[a]; }
object set extends Synchr[unit](this) { case class C(x: a) extends SyncVar[unit]; }
object state extends Asynchr(this) { case class C(x: a); }
rules (
- Pair(List(get, state), { case List(g @ get.C(), state.C(x) ) =>
+ (List(get, state), { case List(g @ get.C(), state.C(x) ) =>
{ g.set(x); state(state.C(x)) } }),
- Pair(List(set, state), { case List(s @ set.C(x), state.C(y) ) =>
+ (List(set, state), { case List(s @ set.C(x), state.C(y) ) =>
{ s.set(()); state(state.C(x)) } })
);
state(state.C(init));
-
+
def Get: a = get(get.C());
def Set(x: a): unit = set(set.C(x));
}
@@ -13,27 +13,27 @@ import concurrent.SyncVar;
/** Implementation in the join-calculus of a parallel OR. */
object or extends Join {
-
+
object res extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
object res1 extends Asynchr(this) { case class C(b: boolean); }
object res2 extends Asynchr(this) { case class C(b: boolean); }
object res1False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
object res2False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
-
+
rules(
- Pair(List(res, res1), { case List(r @ res.C(), res1.C(b)) =>
+ (List(res, res1), { case List(r @ res.C(), res1.C(b)) =>
if (b) r.set(b) else r.set(res1False(res1False.C())) }),
-
- Pair(List(res, res2), { case List(r @ res.C(), res2.C(b)) =>
+
+ (List(res, res2), { case List(r @ res.C(), res2.C(b)) =>
if (b) r.set(b) else r.set(res2False(res2False.C())) }),
-
- Pair(List(res1False, res2), { case List(r @ res1False.C(), res2.C(b)) =>
+
+ (List(res1False, res2), { case List(r @ res1False.C(), res2.C(b)) =>
r.set(b) }),
-
- Pair(List(res2False, res1), { case List(r @ res2False.C(), res1.C(b)) =>
+
+ (List(res2False, res1), { case List(r @ res2False.C(), res1.C(b)) =>
r.set(b) })
);
-
+
def apply(b1: => boolean, b2: => boolean): boolean = {
concurrent.ops.spawn(res1(res1.C(b1)));
concurrent.ops.spawn(res2(res2.C(b2)));
@@ -42,7 +42,7 @@ object or extends Join {
}
*/
object parallelOr {
-
+
def main(args: Array[String]): unit = {
def loop: boolean = { while (true) {}; true };
/*
@@ -14,7 +14,7 @@ object callccInterpreter {
def showM(m: M[Value]): String = (m in id).toString();
- def callCC[A](h: (A => M[A]) => M[A]) =
+ def callCC[A](h: (A => M[A]) => M[A]) =
M[A](c => h(a => M[A](d => c(a))) in c);
type Name = String;
@@ -30,23 +30,23 @@ object callccInterpreter {
trait Value;
case object Wrong extends Value {
override def toString() = "wrong"
- }
+ }
case class Num(n: Int) extends Value {
override def toString() = n.toString();
}
case class Fun(f: Value => M[Value]) extends Value {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -62,15 +62,15 @@ object callccInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
- case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e))
+ case Ccc(x, t) => callCC(k => interp(t, (x, Fun(k)) :: e))
}
- def test(t: Term): String =
+ def test(t: Term): String =
showM(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
@@ -20,15 +20,15 @@ object directInterpreter {
case Fun(f) => "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): Value = e match {
case List() => Wrong
- case Pair(y, b) :: e1 => if (x == y) b else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) b else lookup(x, e1)
}
- def add(a: Value, b: Value): Value = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => Num(m + n)
+ def add(a: Value, b: Value): Value = (a, b) match {
+ case (Num(m), Num(n)) => Num(m + n)
case _ => Wrong
}
@@ -41,15 +41,15 @@ object directInterpreter {
case Var(x) => lookup(x, e)
case Con(n) => Num(n)
case Add(l, r) => add(interp(l, e), interp(r, e))
- case Lam(x, t) => Fun(a => interp(t, Pair(x, a) :: e))
+ case Lam(x, t) => Fun(a => interp(t, (x, a) :: e))
case App(f, t) => apply(interp(f, e), interp(t, e))
}
- def test(t: Term): String =
+ def test(t: Term): String =
showval(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
- def main(args: Array[String]) =
+ def main(args: Array[String]) =
System.out.println(test(term0));
}
@@ -41,15 +41,15 @@ object errorInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]]
+ type Environment = List[Tuple2[Name, Value]]
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => errorM("unbound variable: " + x);
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => errorM("should be numbers: " + a + "," + b)
}
@@ -65,7 +65,7 @@ object errorInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
@@ -22,23 +22,23 @@ object simpleInterpreter {
trait Value;
case object Wrong extends Value {
override def toString() = "wrong"
- }
+ }
case class Num(n: Int) extends Value {
override def toString() = n.toString();
}
case class Fun(f: Value => M[Value]) extends Value {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => unitM(Num(m + n))
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => unitM(Num(m + n))
case _ => unitM(Wrong)
}
@@ -54,14 +54,14 @@ object simpleInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
}
- def test(t: Term): String =
+ def test(t: Term): String =
showM(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
@@ -4,20 +4,20 @@ object stateInterpreter {
type State = Int;
- val tickS = new M(s => Pair((), s + 1));
+ val tickS = new M(s => ((), s + 1));
- case class M[A](in: State => Pair[A, State]) {
- def bind[B](k: A => M[B]) = M[B]{ s0 =>
- val Pair(a, s1) = this in s0; k(a) in s1
+ case class M[A](in: State => Tuple2[A, State]) {
+ def bind[B](k: A => M[B]) = M[B]{ s0 =>
+ val (a, s1) = this in s0; k(a) in s1
}
def map[B](f: A => B): M[B] = bind(x => unitM(f(x)));
def flatMap[B](f: A => M[B]): M[B] = bind(f);
}
- def unitM[A](a: A) = M[A](s => Pair(a, s));
+ def unitM[A](a: A) = M[A](s => (a, s));
def showM(m: M[Value]): String = {
- val Pair(a, s1) = m in 0;
+ val (a, s1) = m in 0;
"Value: " + a + "; Count: " + s1
}
@@ -41,15 +41,15 @@ object stateInterpreter {
override def toString() = "<function>"
}
- type Environment = List[Pair[Name, Value]];
+ type Environment = List[Tuple2[Name, Value]];
def lookup(x: Name, e: Environment): M[Value] = e match {
case List() => unitM(Wrong)
- case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
+ case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
}
- def add(a: Value, b: Value): M[Value] = Pair(a, b) match {
- case Pair(Num(m), Num(n)) => for (_ <- tickS) yield Num(m + n)
+ def add(a: Value, b: Value): M[Value] = (a, b) match {
+ case (Num(m), Num(n)) => for (_ <- tickS) yield Num(m + n)
case _ => unitM(Wrong)
}
@@ -65,14 +65,14 @@ object stateInterpreter {
b <- interp(r, e);
c <- add(a, b))
yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e)))
+ case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
case App(f, t) => for (a <- interp(f, e);
b <- interp(t, e);
c <- apply(a, b))
yield c
}
- def test(t: Term): String =
+ def test(t: Term): String =
showM(interp(t, List()));
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
@@ -13,24 +13,24 @@ object patterns {
case Leaf(x) => x
}
- def find[a,b](it: Iterator[Pair[a, b]], x: a): Option[b] = {
+ def find[a,b](it: Iterator[Tuple2[a, b]], x: a): Option[b] = {
var result: Option[b] = None
var found = false
while (it.hasNext && !found) {
- val Pair(x1, y) = it.next
+ val (x1, y) = it.next
if (x == x1) { found = true; result = Some(y) }
}
result
}
- def printFinds[a](xs: List[Pair[a, String]], x: a) =
+ def printFinds[a](xs: List[Tuple2[a, String]], x: a) =
find(xs.iterator, x) match {
case Some(y) => System.out.println(y)
case None => System.out.println("no match")
}
def main(args: Array[String]) {
println("sum of leafs=" + sumLeaves(tree1))
- printFinds(List(Pair(3, "three"), Pair(4, "four")), 4)
+ printFinds(List((3, "three"), (4, "four")), 4)
}
}
@@ -8,7 +8,7 @@ object elasticBuffer {
* Recursive type for channels that carry a "String" channel and
* an object of the type we define.
*/
- class MetaChan extends Chan[Pair[Chan[String], MetaChan]]
+ class MetaChan extends Chan[Tuple2[Chan[String], MetaChan]]
def Buffer(put: Chan[String], get: Chan[String]): Unit = {
@@ -18,19 +18,19 @@ object elasticBuffer {
def Bl(i:Chan[String], l: MetaChan,
o: Chan[String], r: MetaChan): unit =
choice (
- l(Pair(o,r)) * (System.out.println("Removed one cell.")),
+ l((o,r)) * (System.out.println("Removed one cell.")),
i * (inp => Cl(i, l, o, r, inp))
)
/**
* A buffer cell containing a value, ready to receive (o,r) from the right.
*/
- def Cl(i: Chan[String], l: MetaChan,
+ def Cl(i: Chan[String], l: MetaChan,
o: Chan[String], r: MetaChan, content: String): Unit =
choice (
o(content) * (Bl(i,l,o,r)),
i * (inp => Dl(i,l,o,r,content, inp)),
- r * ( { case Pair(newo, newr) => Cl(i,l,newo,newr,content) })
+ r * ( { case (newo, newr) => Cl(i,l,newo,newr,content) })
)
/**
Oops, something went wrong.

0 comments on commit b004c3d

Please sign in to comment.