Hello ocaml list,
I have a list of name constructor pairs and from that list I want to define a set of recursive types. I've written the following function:

let type_chain _loc  lst =
  let rec iter sofar =
    function
      | [] -> sofar
      | (name,constructors) :: ys ->
      iter <:str_item< $sofar$ and $lid:name$ = $constructor$  >> ys
  in
    match lst with
    (name,constructors) :: ys ->
      iter <:str_item< type $lid:name$ = $constructors$ >> ys
      | _ -> raise (Failure "no types defined")

which, unfortunately, fails to type check with the error:

"
While expanding quotation "str_item" in a position of "expr":
  Parse error: illegal begin of quotation of structure item
"

how would I go about writing such a function?

--Jacques L