From: Joel Reymont <joelr1@gmail.com>
To: Caml List <caml-list@inria.fr>
Subject: camlp4 3.10: Hashtbl.t and <:ctyp< $tp1$ . $tp2$ >>
Date: Mon, 30 Apr 2007 22:52:50 +0100 [thread overview]
Message-ID: <85C23368-5DC3-4ECB-BEBA-EB98E5140E33@gmail.com> (raw)
Consider the following function. My understanding is that for, say,
Hashtbl.t it should return a list of types where the 1st element
represents "t" and the second represents "Hashtbl".
(* [tp_path tp] takes a type. @return a module path (list of strings)
denoting this type. *)
let rec tp_path = function
| <:ctyp< $lid:id$ >> | <:ctyp< $uid:id$ >> -> [id]
| <:ctyp< $tp1$ . $tp2$ >> ->
(match tp_path tp2 with [n] -> n | _ -> assert false) ::
tp_path tp1
| _ -> invalid_arg "tp_path"
Nicolas suggested the following approach which doesn't work because
tp1 and tp2 become idents. There's a function to convert from ctyp to
ident but I could not find the opposite from searching the camlp4
source tree.
let rec tp_path = function
| <:ctyp< $lid:id$ >> | <:ctyp< $uid:id$ >> -> [id]
| <:ctyp< $id:id$ >> ->
(match id with
| <:ident< $tp1$ . $tp2$ >> ->
(match tp_path tp2 with [n] -> n | _ -> assert false) ::
tp_path tp1
| _ -> invalid_arg "tp_path")
| _ -> invalid_arg "tp_path"
Since Hashtbl.t is a valid type, there should be a camlp4 ctyp
pattern to match it, no?
Am I missing something obvious?
Thanks, Joel
--
http://wagerlabs.com/
next reply other threads:[~2007-04-30 21:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-30 21:52 Joel Reymont [this message]
2007-05-01 7:26 ` [Caml-list] " Nicolas Pouillard
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=85C23368-5DC3-4ECB-BEBA-EB98E5140E33@gmail.com \
--to=joelr1@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