caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Le Normand <rathereasy@gmail.com>
To: caml-list caml-list <caml-list@yquem.inria.fr>
Subject: defining recursive types with camlp4
Date: Sun, 14 Jun 2009 17:10:29 -0400	[thread overview]
Message-ID: <f74178430906141410y4327d84r7223cb87bdc83e38@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2009-06-14 21:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-14 21:10 Jacques Le Normand [this message]
2009-06-14 22:11 ` [Caml-list] " blue storm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f74178430906141410y4327d84r7223cb87bdc83e38@mail.gmail.com \
    --to=rathereasy@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).