From: bluestorm <bluestorm.dylc@gmail.com>
To: Florent Ouchet <florent.ouchet@imag.fr>
Cc: "Hezekiah M. Carty" <hcarty@atmos.umd.edu>,
caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] OCaml 3.12.0+beta1
Date: Fri, 25 Jun 2010 10:17:46 +0200 [thread overview]
Message-ID: <AANLkTilObXVbEfPuBWf-fDprgu0oi16xMve7inu2FDIb@mail.gmail.com> (raw)
In-Reply-To: <20100625082404.19864c8w6r8962kk@webmail.imag.fr>
[-- Attachment #1: Type: text/plain, Size: 1444 bytes --]
Here is a small Camlp4 filter removing exhaustive patterns. It obviously
depends on 3.12.
open Camlp4.PreCast;;
let filter =
function
| <:patt@_loc< { $p$ } >> ->
let rec clean = function
| <:patt< _ ; $p$ >> | <:patt< $p$; _ >> -> clean p
| <:patt@_loc< $p1$; $p2$ >> -> <:patt< $clean p1$; $clean p2$ >>
| p -> p in
<:patt< { $clean p$ } >>
| t -> t
;;
AstFilters.register_str_item_filter (Ast.map_patt filter)#str_item;;
(*
#step I used to compile and test the code from a freshly compiiled (but
not installed) ocaml-3.12 beta :
#I build using fastworld.sh (see INSTALL) then `cd _build`
../byterun/ocamlrun -I otherlibs/unix/ camlp4/camlp4orf.byte /tmp/
exhaustive_record_stripper.ml -o /tmp/stripper.ml
../byterun/ocamlrun ./ocamlc -I stdlib -I camlp4 /tmp/stripper.ml -c
../byterun/ocamlrun -I otherlibs/unix/ camlp4/camlp4o.byte
/tmp/stripper.cmo -str 'fun {a; b; _} -> c'
#output : fun { a = a; b = b } -> c
*)
Notes :
- that the OCaml printer expand sugared { a; b } patters into { a = a; b = b
} is necessary for printing backward-compatible code; I'm not sure it's a
good idea to rely on this.
- as with every camlp4 filters, the code is parsed then pretty-printed; do
not expect indentation to stay as is. Comment placement is also going to do
weird things (know and nearly-unfixable camlp4 defect) : ocamldoc may not
work properly on the output code.
[-- Attachment #2: Type: text/html, Size: 2031 bytes --]
next prev parent reply other threads:[~2010-06-25 8:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-16 13:07 Damien Doligez
2010-06-16 16:28 ` [Caml-list] " Yoann Padioleau
2010-06-16 18:40 ` Martin Jambon
2010-06-16 20:52 ` Török Edwin
2010-06-17 13:35 ` xclerc
2010-06-18 14:56 ` xclerc
2010-06-19 5:51 ` Stéphane Glondu
2010-06-24 9:38 ` Florent Ouchet
2010-06-24 17:45 ` Martin Jambon
2010-06-24 18:59 ` Florent.Ouchet
2010-06-24 19:29 ` Dmitry Bely
2010-06-24 19:31 ` Mathias Kende
2010-06-24 19:39 ` Till Varoquaux
2010-06-24 20:49 ` Florent Ouchet
2010-06-24 20:57 ` Hezekiah M. Carty
2010-06-24 22:05 ` Florent Ouchet
2010-06-25 5:54 ` bluestorm
2010-06-25 6:24 ` Florent Ouchet
2010-06-25 8:17 ` bluestorm [this message]
2010-06-25 8:48 ` David Allsopp
2010-06-25 9:35 ` bluestorm
2010-06-25 7:29 ` bluestorm
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=AANLkTilObXVbEfPuBWf-fDprgu0oi16xMve7inu2FDIb@mail.gmail.com \
--to=bluestorm.dylc@gmail.com \
--cc=caml-list@inria.fr \
--cc=florent.ouchet@imag.fr \
--cc=hcarty@atmos.umd.edu \
/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