Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Joel Reymont <joelr1@gmail.com>
To: Nicolas Pouillard <nicolas.pouillard@gmail.com>
Cc: "Caml List" <caml-list@inria.fr>
Subject: Re: Upgrading sexplib-2.7.0 to camlp4 3.10
Date: Tue, 1 May 2007 17:14:26 +0100	[thread overview]
Message-ID: <FD5A8341-61E5-42E4-AE9D-48F0643C3ED6@gmail.com> (raw)
In-Reply-To: <cd67f63a0705010849r6a2bd1dfj8fae7a69f8b561c3@mail.gmail.com>

RfTag is gone, apparently. How do you process variants then?

The only reference to constructors I could find is with_constr in  
Camlp4Ast.partial.ml. It's applicable to modules, apparently.

The original code is attached below.

    Thanks, Joel

---

   and sexp_of_variants_loop _loc acc = function
     | RfTag (cnstr, _, []) ->
         (
           <:patt< `$cnstr$ >>,
           None,
           <:expr< Sexplib.Sexp.Atom $str:cnstr$ >>
         ) :: acc
     | RfTag (cnstr, _, tps) ->
         let fps = List.map (sexp_of_type _loc) tps in
         let bindings, patts, vars = Gen.mk_bindings _loc fps in
         let arg_patt = tuplify_patts _loc patts in
         let cnstr_expr = <:expr< Sexplib.Sexp.Atom $str:cnstr$ >> in
         (
           <:patt< `$cnstr$ $arg_patt$ >>,
           None,
           <:expr<
             let $list:bindings$ in
             Sexplib.Sexp.List $Gen.mk_expr_lst _loc (cnstr_expr ::  
vars)$
           >>
         ) :: acc
     | RfInh (TyVrn (_loc, row_fields, _)) ->
         List.fold_left (sexp_of_variants_loop _loc) acc row_fields
     | RfInh tp ->
         let tp_path, call =
           match tp with
           | <:ctyp< $tp1$ $tp2$ >> ->
               let fp1 = sexp_of_type _loc tp1 in
               let fp2 = sexp_of_type _loc tp2 in
               let tp_path = List.rev (Gen.tp_path (get_appl_path  
_loc tp1)) in
               let expr = sexp_of_appl_fun _loc fp1 fp2 in
               tp_path, expr
           | _ ->
               let tp_path = Gen.tp_path tp in
               match tp_path with
               | tn :: path -> tp_path, mk_abst_call _loc tn path
               | [] -> assert false  (* impossible *)
         in
         (
           <:patt< (#$tp_path$ as v) >>,
           None,
           <:expr< $call$ v >>
         ) :: acc

   and sexp_of_variant _loc row_fields =
     `Match (
       List.rev (List.fold_left (sexp_of_variants_loop _loc) []  
row_fields))

--
http://wagerlabs.com/






  reply	other threads:[~2007-05-01 16:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-30 13:55 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 [this message]
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                                       ` [Caml-list] " Dmitry Bely
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=FD5A8341-61E5-42E4-AE9D-48F0643C3ED6@gmail.com \
    --to=joelr1@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=nicolas.pouillard@gmail.com \
    /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