Skip to content

Instantly share code, notes, and snippets.

@avsm
Forked from jaked/gist:166609
Created August 12, 2009 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avsm/166645 to your computer and use it in GitHub Desktop.
Save avsm/166645 to your computer and use it in GitHub Desktop.
(* defines the Ast.binding for a function of form:
let fun_name ?(opt_arg1) ?(opt_arg2) final_ident = function_body ...
*)
let function_with_label_args _loc ~fun_name ~final_ident ~function_body ~return_type opt_args =
let opt_args = opt_args @ [ <:patt< $lid:final_ident$ >> ] in
<:binding< $lid:fun_name$ =
$List.fold_right (fun b a ->
<:expr<fun $b$ -> $a$ >>
) opt_args <:expr< ( $function_body$ : $return_type$ ) >>
$ >>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment