Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Yaron Minsky <yminsky@janestreet.com>
To: "Matej Košík" <5764c029b688c1c0d24a2e97cd764f@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] concerning using of `deriving' syntactic plugin
Date: Wed, 7 Mar 2012 07:34:24 -0500	[thread overview]
Message-ID: <CACLX4jRpM=FmeCF9Q9ZB+o-hTTbKaR2R2fAU2HtFjPjFyqf3pw@mail.gmail.com> (raw)
In-Reply-To: <4F574B3C.5000207@gmail.com>

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

Are you familiar with type-conv and the family of syntax-extensions that go
along with it?  You can do thinks like:

type t = { foo: int; bar: string }
with sexp, compare, bin_io


and automatically get sexp-conversion functions, a comparison function, and
binary protocol converters.  And type-conv has been used to build other
type-directed functions by other people outside of Jane Street.

The latest version is available on bitbucket, and we'll have a new blessed
release in a few days.

https://bitbucket.org/yminsky/ocaml-core/


Note that this is done purely syntactically, and yet gets you there.

y

On Wed, Mar 7, 2012 at 6:49 AM, Matej Košík <
5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote:

> Hi,
>
> I would like to print out the response of a modified Ocaml's typechecker
> to various inputs.
>
> One way to do it would be to write a pretty-printer by hand.
>
> Before I do that, I would like to apply "deriving" machinery:
> http://code.google.com/p/deriving/wiki/Introduction
> to this (chore) job.
>
> In some cases I do not know what to do.
>
> E.g., file "types/types.mli" contains the following definition:
>
>  and value_kind =
>      Val_reg
>    | Val_prim of Primitive.description
>    | Val_ivar of mutable_flag * string
>    | Val_self of
>        (Ident.t * type_expr) Meths.t ref *
>        (Ident.t * mutable_flag * virtual_flag * type_expr) Vars.t ref *
>      string * type_expr
>    | Val_anc of (string * Ident.t) list * string
>    | Val_unbound
>
> If I add
>
>  deriving (Show)
>
> at the end of the above definition, I get an error:
>
>  Error: Unbound module Meths.Show_t
>
> That is expected but I am not sure what to do. That is, I am not sure
> what is the official way to "deriving"-sify the "Meth" module which
> defined in the following way:
>
>  module Meths = Map.Make(OrderedString)
>
> without the need to modify files "map.ml{i,}".
>
> Is something like that possible?
>
> Thank you very much in advance for any help.
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/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: 3622 bytes --]

  parent reply	other threads:[~2012-03-07 12:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-07 11:49 Matej Košík
2012-03-07 12:31 ` Gabriel Scherer
2012-03-07 16:44   ` Matej Košík
2012-03-07 17:06     ` Jérémie Dimino
2012-03-07 12:34 ` Yaron Minsky [this message]
2012-03-07 16:44   ` Matej Košík
2012-03-07 17:10     ` Markus Mottl
2012-03-07 17:28       ` Matej Košík
2012-03-07 20:47         ` Till Varoquaux
2012-03-08  2:49         ` Markus Mottl

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='CACLX4jRpM=FmeCF9Q9ZB+o-hTTbKaR2R2fAU2HtFjPjFyqf3pw@mail.gmail.com' \
    --to=yminsky@janestreet.com \
    --cc=5764c029b688c1c0d24a2e97cd764f@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