caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Louis Roché" <louis@louisroche.net>
To: Francois Berenger <francois.berenger@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Is it possible to get back some OCaml code after ppx processing ?
Date: Wed, 23 Mar 2016 18:02:49 +0100	[thread overview]
Message-ID: <CAGcHsw8XV3Gd_vJB0jpc+-9+zx29_Tg84NyoiM0xDhV9iYgQ6w@mail.gmail.com> (raw)
In-Reply-To: <56F2C6D7.3080707@inria.fr>

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

Hi,

1) With utop, you will get what you want:

utop # type t = {
  i: int;
  f: float
} [@@deriving eq,show];;
type t = { i : int; f : float; }
val equal : t -> t -> bool = <fun>
val pp : Format.formatter -> t -> unit = <fun>
val show : t -> bytes = <fun>

2) I believe that you are looking for an option like -dsource for ocamlc

Louis


2016-03-23 17:39 GMT+01:00 Francois Berenger <francois.berenger@inria.fr>:

> Dear list,
>
> I am completely new to the -ppx option of the compiler, so please
> forgive in advance my (probably stupid) two questions.
>
> Here is some example code:
> ---
> type t = {
>   i: int;
>   f: float
> } [@@deriving sexp]
> ---
>
> 1) I'd like to see all the functions automatically created
> by the magical spell "[@@deriving sexp]".
> At least their names and type signatures would be nice.
> How to do that?
>
> 2) If that's not possible, I'd like to get back some
> OCaml code corresponding to the AST after ppx processing.
> If that's possible, how to do that?
>
> Thanks a lot,
> Francois.
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 2154 bytes --]

  reply	other threads:[~2016-03-23 17:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-23 16:39 Francois Berenger
2016-03-23 17:02 ` Louis Roché [this message]
2016-03-24  9:27   ` Goswin von Brederlow
2016-03-24 10:37     ` Jeremie Dimino
2016-03-23 17:05 ` Nicolas Ojeda Bar

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=CAGcHsw8XV3Gd_vJB0jpc+-9+zx29_Tg84NyoiM0xDhV9iYgQ6w@mail.gmail.com \
    --to=louis@louisroche.net \
    --cc=caml-list@inria.fr \
    --cc=francois.berenger@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).