caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Dmitry Bely" <dmitry.bely@gmail.com>
To: "Caml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] camlp4 3.10: Matching variant types
Date: Thu, 3 May 2007 09:58:58 +0400	[thread overview]
Message-ID: <90823c940705022258h26c7dc34t448013ac7127c644@mail.gmail.com> (raw)
In-Reply-To: <D2B05A08-340F-440A-97ED-F59F506AFA06@gmail.com>

Probably the following is related to Joel's questions on variant type
matching. I am trying to convert IoXML syntax extension to the new
camlp4. Currently I am stuck here:

...
value gen_output_cons (loc, c, tl) =
  let p =
    let p = <:patt< $uid:c$ >> in
    let (p, _) =
      List.fold_left
        (fun (p, cnt) _ ->
           let p = <:patt< $p$ $lid:pname cnt$ >> in
           (p, cnt + 1))
        (p, 1) tl
    in
    p
  in
  let e = gen_xprint_cons loc c tl in
  (p, None, e)
;
...
value gen_output_sum loc cdl =
  let mc =
    List.fold_right
      (fun cd mc ->
        let (p, _, e) = gen_output_cons cd in
          <:match_case< $p$ -> $e$ | $mc$ >>)
	  cdl <:match_case<>> in
  <:expr< fun ppf -> fun [ $mc$ ] >>
;
...
value gen_output_funs loc tdl sil =
  let pel =
    List.fold_right
      (fun ((loc, n), tpl, tk, cl) pel ->
         let body =
           loop tk where rec loop =
             fun
             [ <:ctyp< [ $cdl$ ] >> -> gen_output_sum loc cdl

File "pa_ioXML.ml", line 257, characters 58-61:
This expression has type Camlp4.PreCast.Ast.ctyp but is here used with type
  (Camlp4.PreCast.Ast.Loc.t * string * Camlp4.PreCast.Ast.ctyp list) list

As usual: (cdl) was a list before, now it is not. Is were a simple way
to get a list and make (gen_output_sum) happy? Or this should be
complete rewritten - how?

- Dmitry Bely


  reply	other threads:[~2007-05-03  5:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-30 13:55 Upgrading sexplib-2.7.0 to camlp4 3.10 Joel Reymont
2007-04-30 14:01 ` Nicolas Pouillard
2007-04-30 14:07   ` Joel Reymont
2007-04-30 14:17     ` Nicolas Pouillard
2007-04-30 14:31       ` Joel Reymont
2007-04-30 14:46       ` Joel Reymont
2007-04-30 15:19         ` Nicolas Pouillard
2007-04-30 15:29           ` Joel Reymont
2007-04-30 15:46             ` Nicolas Pouillard
2007-04-30 19:44               ` Joel Reymont
2007-04-30 21:08                 ` Joel Reymont
2007-05-01  7:20                   ` Nicolas Pouillard
2007-05-01 13:21                     ` Joel Reymont
2007-05-01 13:35                       ` Nicolas Pouillard
2007-05-01 13:54                         ` Joel Reymont
2007-05-01 14:16                           ` Nicolas Pouillard
2007-05-01 14:31                             ` Joel Reymont
2007-05-01 15:49                               ` Nicolas Pouillard
2007-05-01 16:14                                 ` Joel Reymont
2007-05-01 16:27                                   ` Nicolas Pouillard
2007-05-01 16:35                                     ` Joel Reymont
2007-05-01 16:39                                       ` Nicolas Pouillard
2007-05-01 16:50                                         ` Joel Reymont
2007-05-01 17:13                                           ` Nicolas Pouillard
2007-05-01 17:04                                     ` camlp4 3.10: Matching variant types Joel Reymont
2007-05-03  5:58                                       ` Dmitry Bely [this message]
2007-05-01 16:05                             ` Upgrading sexplib-2.7.0 to camlp4 3.10 Joel Reymont
2007-05-01 16:19                               ` Nicolas Pouillard
2007-04-30 21:16               ` Joel Reymont

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=90823c940705022258h26c7dc34t448013ac7127c644@mail.gmail.com \
    --to=dmitry.bely@gmail.com \
    --cc=caml-list@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).