//  Copyright © 2015 Rob Rix. All rights reserved.

enum ABT<Applied, Recur> {
	case Variable(Name)
	case Abstraction(Name, Recur)
	case Constructor(Applied)
}

indirect enum ABTTerm {
	case In(Set<Name>, ABT<AST<ABTTerm>, ABTTerm>)

	var freeVariables: Set<Name> {
		guard case let .In(variables, _) = self else { return [] }
		return variables
	}

	var out: ABT<AST<ABTTerm>, ABTTerm> {
		switch self {
		case let .In(_, out):
			return out
		}
	}
}

enum AST<Recur> {
	case Lambda(Recur)
	case Application(Recur, Recur)
}

//  Copyright © 2015 Rob Rix. All rights reserved.

enum ABT<Applied, Recur> {
	case Variable(Name)
	case Abstraction(Name, Recur)
	case Constructor(Applied)
}

indirect enum ABTTerm {
	case In(Set<Name>, ABT<AST<ABTTerm>, ABTTerm>)

	var freeVariables: Set<Name> {
		guard case let .In(variables, _) = self else { return [] }
		return variables
	}
}

enum AST<Recur> {
	case Lambda(Recur)
	case Application(Recur, Recur)
}

--- 
+++ 
@@ -13,6 +13,13 @@
 		guard case let .In(variables, _) = self else { return [] }
 		return variables
 	}
+
+	var out: ABT<AST<ABTTerm>, ABTTerm> {
+		switch self {
+		case let .In(_, out):
+			return out
+		}
+	}
 }
 
 enum AST<Recur> {
Add a property to retrieve the binding tree.
