module Flatten;
data Tree = Leaf(A) | Node(Tree, Tree);
def List cons(A x, List xs) = Cons(x,xs);
// higher order constructs are not supported!
def B comp(f, g)(A x) = f(g(x));
// let rec walk t =
// match t with
// | Leaf(x) -> cons x
// | Node(t1,t2) -> comp (walk t1) (walk t2)
// ;;
def B walk(Tree t) =
case t {
Leaf(x) => ((List xs) => cons(x,xs)); // Error: Higher-order constructs are not supported!
Node(t1,t2) => (List xs => comp(walk(t1), walk(t2))(xs));
};
// let flatten t = walk t Nil
// ;;
{
}