diff --git a/lib/compiler/syntactic_ast.ml b/lib/compiler/syntactic_ast.ml index ea4460b..23be618 100644 --- a/lib/compiler/syntactic_ast.ml +++ b/lib/compiler/syntactic_ast.ml @@ -34,13 +34,7 @@ type top_level = (* we use result here to make things nicer *) let ( let* ) = Result.bind -let traverse f l = - let rec aux acc = function - | x :: xs -> - let* result = f x in - aux (result :: acc) xs - | [] -> Ok (List.rev acc) in - aux [] l +let traverse = Util.traverse let map = List.map diff --git a/lib/compiler/util.ml b/lib/compiler/util.ml new file mode 100644 index 0000000..71512db --- /dev/null +++ b/lib/compiler/util.ml @@ -0,0 +1,9 @@ +let ( let* ) = Result.bind + +let traverse f l = + let rec aux acc = function + | x :: xs -> + let* result = f x in + aux (result :: acc) xs + | [] -> Ok (List.rev acc) in + aux [] l