From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q27CYXiq028799 for ; Wed, 7 Mar 2012 13:34:33 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao4CAPhUV08machzl2dsb2JhbABDhTSeBYhPAYkFKgEBAQEBCBYHO4IKAQEBAwESAg8dAQEsCwEECwkCCxodAgIhARIBBQEKEgYTEhCHYQUDCJwUCoo7bYM9AY52Bok5hiCBFoJhhXWMb4shgxg9hCI X-IronPort-AV: E=Sophos;i="4.73,545,1325458800"; d="scan'208";a="148024833" Received: from mx2.janestreet.com (HELO nyc-dmz-mxout2.janestreet.com) ([38.105.200.115]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Mar 2012 13:34:27 +0100 Received: from nyc-qsv-mail1.delacy.com ([172.25.22.57]) by nyc-dmz-mxout2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1S5G4X-0000w3-B5 for caml-list@inria.fr; Wed, 07 Mar 2012 07:34:25 -0500 Received: from nyc-dmz-mxgoog1.delacy.com ([172.25.224.109] helo=mxgoog1.janestreet.com) by nyc-qsv-mail1.delacy.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1S5G4X-0005qC-9v for caml-list@inria.fr; Wed, 07 Mar 2012 07:34:25 -0500 Received: from mail-gy0-f170.google.com ([209.85.160.170]) by mxgoog1.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1S5G4X-00012Q-7C for caml-list@inria.fr; Wed, 07 Mar 2012 07:34:25 -0500 Received: by ghbg2 with SMTP id g2so3180068ghb.29 for ; Wed, 07 Mar 2012 04:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=SatGrM9frhn0yw0kIWcvsspHoWzVmaYRK3kATMNteWw=; b=BvCLuHRyXgXV6JdXo71VjVQP0MSWWpJ75prWPUqynagNmvqrSzeJ88N4XxSaozIff3 sBI1UvZiUhXYIpgoPH9BZqvbHqTNqS5fiCKKz+FdZ97XmR4bBV64WF00iGGmkpgXX8JI OyMqk4RWzI+a5Zrs22Z+9sjHOFV3I2boWkmYQ= MIME-Version: 1.0 Received: by 10.60.9.103 with SMTP id y7mr659937oea.58.1331123664607; Wed, 07 Mar 2012 04:34:24 -0800 (PST) Received: by 10.182.43.170 with HTTP; Wed, 7 Mar 2012 04:34:24 -0800 (PST) X-Originating-IP: [72.225.238.212] In-Reply-To: <4F574B3C.5000207@gmail.com> References: <4F574B3C.5000207@gmail.com> Date: Wed, 7 Mar 2012 07:34:24 -0500 Message-ID: From: Yaron Minsky To: =?UTF-8?B?TWF0ZWogS2/FocOtaw==?= <5764c029b688c1c0d24a2e97cd764f@gmail.com> Cc: Caml List Content-Type: multipart/alternative; boundary=e89a8fb1f8c82e59d104baa66135 X-Gm-Message-State: ALoCoQkydO2gjwjVJGR+naUFsdnlaUvMEboKfEH5yIcWoSCTofpz7NEwRtHnbbYpHzpggF28HBFC Subject: Re: [Caml-list] concerning using of `deriving' syntactic plugin --e89a8fb1f8c82e59d104baa66135 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Are you familiar with type-conv and the family of syntax-extensions that go along with it? You can do thinks like: type t =3D { 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=C5=A1=C3=ADk < 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 =3D > 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 =3D 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 > > --e89a8fb1f8c82e59d104baa66135 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Are you familiar with type-conv and the family of syntax-extensions that go= along with it? =C2=A0You can do thinks like:

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

and automatic= ally get sexp-conversion functions, a comparison function, and binary proto= col converters. =C2=A0And type-conv has been used to build other type-direc= ted functions by other people outside of Jane Street.

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


Note that this is done purely syntacticall= y, and yet gets you there.

y

On Wed, Mar 7, 2012 at 6:49 AM, Matej Ko=C5=A1=C3=ADk <5= 764c029b688c1c0d24a2e97cd764f@gmail.com> wrote:
Hi,

I would like to print out the response of a modified Ocaml's typechecke= r
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:
=C2=A0and value_kind =3D
=C2=A0 =C2=A0 =C2=A0Val_reg
=C2=A0 =C2=A0| Val_prim of Primitive.description
=C2=A0 =C2=A0| Val_ivar of mutable_flag * string
=C2=A0 =C2=A0| Val_self of
=C2=A0 =C2=A0 =C2=A0 =C2=A0(Ident.t * type_expr) Meths.t ref *
=C2=A0 =C2=A0 =C2=A0 =C2=A0(Ident.t * mutable_flag * virtual_flag * type_e= xpr) Vars.t ref *
=C2=A0 =C2=A0 =C2=A0string * type_expr
=C2=A0 =C2=A0| Val_anc of (string * Ident.t) list * string
=C2=A0 =C2=A0| Val_unbound

If I add

=C2=A0deriving (Show)

at the end of the above definition, I get an error:

=C2=A0Error: 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:

=C2=A0module Meths =3D 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. =C2=A0Subscription 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


--e89a8fb1f8c82e59d104baa66135--