summaryrefslogtreecommitdiff
path: root/docs/examples/monads/errorInterpreter.scala
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/monads/errorInterpreter.scala')
-rw-r--r--docs/examples/monads/errorInterpreter.scala10
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/examples/monads/errorInterpreter.scala b/docs/examples/monads/errorInterpreter.scala
index d3cc45627d..c15e1041e2 100644
--- a/docs/examples/monads/errorInterpreter.scala
+++ b/docs/examples/monads/errorInterpreter.scala
@@ -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))