 public func foldl<A, B>(f: (B, A) -> B) -> B -> [A] -> B {
 	return { z in { l in
 		switch match(l) {
-			case .Empty:
+			case .Nil:
 				return z
 			case .Cons(let x, let xs):
 				return foldl(f)(f(z, x))(xs)
+		}
+	} }
+}
+
+/// Takes a binary function, a starting value, and a list of values, then folds the function over
+/// the list from left to right to yield a final value.
+public func foldl<A, B>(f: B -> A -> B) -> B -> List<A> -> B {
+	return { z in { l in
+		switch l.match() {
+		case .Nil:
+			return z
+		case .Cons(let x, let xs):
+			return foldl(f)(f(z)(x))(xs)
+		}
+	} }
+}
+
+/// Takes a binary operator, a starting value, and a list of values, then folds the function over
+/// the list from left to right to yield a final value.
+public func foldl<A, B>(f: (B, A) -> B) -> B -> List<A> -> B {
+	return { z in { l in
+		switch l.match() {
+		case .Nil:
+			return z
+		case .Cons(let x, let xs):
+			return foldl(f)(f(z, x))(xs)
 		}
 	} }
 }

	return foldl1(min)(l)
}

/// Returns the sum of a list of numbers.
public func sum<N : IntegerType>(l : [N]) -> N {
	return foldl({ $0 + $1 })(0)(l)

public func foldr<A, B>(k: A -> B -> B) -> B -> [A] -> B {
	return { z in { l in
		switch match(l) {
			case .Nil:
				return z
			case .Cons(let x, let xs):
				return k(x)(foldr(k)(z)(xs))
