caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* defining recursive types with camlp4
@ 2009-06-14 21:10 Jacques Le Normand
  2009-06-14 22:11 ` [Caml-list] " blue storm
  0 siblings, 1 reply; 2+ messages in thread
From: Jacques Le Normand @ 2009-06-14 21:10 UTC (permalink / raw)
  To: caml-list caml-list

[-- Attachment #1: Type: text/plain, Size: 760 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 926 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-06-14 22:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-14 21:10 defining recursive types with camlp4 Jacques Le Normand
2009-06-14 22:11 ` [Caml-list] " blue storm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).