caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] how to apply an attribute on ppx output
@ 2015-11-24 18:52 Ashish Agarwal
  2015-11-24 19:02 ` Leo White
  0 siblings, 1 reply; 5+ messages in thread
From: Ashish Agarwal @ 2015-11-24 18:52 UTC (permalink / raw)
  To: Caml List

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

$ cat foo.mli
type t

$ cat foo.ml
type t = {a:int} [@@deriving fields]

$ ocamlfind ocamlc -package ppx_fields_conv,fieldslib -w A -c foo.mli

$ ocamlfind ocamlc -package ppx_fields_conv,fieldslib -w A -c foo.ml
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value names.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value make_creator.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value create.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value map.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value iter.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value fold.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value map_poly.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value for_all.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value exists.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value to_list.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value iter.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value fold.
File "foo.ml", line 1, characters 5-6:
Warning 32: unused value set_all_mutable_fields.

Thus, I'd like to disable warning 32, but only for the items generated by
the ppx extension. I've tried adding [@@warning "-32"] in various places
but it understandably doesn't work. So then I tried defining an internal
module and disabling in the entire module like this:

$ cat foo.ml
module T = struct
  [@@warning "-32"]
  type t = {a:int} [@@deriving fields]
end
include T

However I get a syntax error, even though this follows the example of the
manual in section 7.221
<http://caml.inria.fr/pub/docs/manual-ocaml/extn.html#sec242>. Is this a
bug in the manual? According to the grammar it seems the attribute should
be added after the module expression:

$ cat foo.ml
module T = struct
  type t = {a:int} [@@deriving fields]
end [@@warning "-32"]

include T

This compiles, but the warnings don't go away. Is there a solution?

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] how to apply an attribute on ppx output
  2015-11-24 18:52 [Caml-list] how to apply an attribute on ppx output Ashish Agarwal
@ 2015-11-24 19:02 ` Leo White
  2015-11-24 19:25   ` octachron
  0 siblings, 1 reply; 5+ messages in thread
From: Leo White @ 2015-11-24 19:02 UTC (permalink / raw)
  To: caml-list

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

> $ cat foo.ml module T = struct  [@@warning "-32"]  type t = {a:int}
> [@@deriving fields] end include T
>
> However I get a syntax error, even though this follows the example of
> the manual in section 7.221[1]. Is this a bug in the manual?

I think that's a typo in the manual: it should be [@@@warning "-32"]
(with *three* at symbols).

Regards,

Leo


Links:

  1. http://caml.inria.fr/pub/docs/manual-ocaml/extn.html#sec242

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] how to apply an attribute on ppx output
  2015-11-24 19:02 ` Leo White
@ 2015-11-24 19:25   ` octachron
  2015-11-24 21:17     ` Ashish Agarwal
  0 siblings, 1 reply; 5+ messages in thread
From: octachron @ 2015-11-24 19:25 UTC (permalink / raw)
  To: caml-list


> I think that's a typo in the manual: it should be [@@@warning "-32"] 
> (with *three* at symbols).
> Regards,
> Leo

It is a typo in the manual – that have already been corrected in the dev 
version of the manual.

Regards,
octachron.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] how to apply an attribute on ppx output
  2015-11-24 19:25   ` octachron
@ 2015-11-24 21:17     ` Ashish Agarwal
  2015-11-25 11:33       ` Jeremie Dimino
  0 siblings, 1 reply; 5+ messages in thread
From: Ashish Agarwal @ 2015-11-24 21:17 UTC (permalink / raw)
  To: octachron; +Cc: Caml List

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

Thanks.

On Tue, Nov 24, 2015 at 2:25 PM, octachron <octa@polychoron.fr> wrote:

>
> I think that's a typo in the manual: it should be [@@@warning "-32"] (with
>> *three* at symbols).
>> Regards,
>> Leo
>>
>
> It is a typo in the manual – that have already been corrected in the dev
> version of the manual.
>
> Regards,
> octachron.
>
> --
> 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: 1383 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] how to apply an attribute on ppx output
  2015-11-24 21:17     ` Ashish Agarwal
@ 2015-11-25 11:33       ` Jeremie Dimino
  0 siblings, 0 replies; 5+ messages in thread
From: Jeremie Dimino @ 2015-11-25 11:33 UTC (permalink / raw)
  To: Ashish Agarwal; +Cc: octachron, Caml List

BTW, if you use ppx_driver, it will use the specific ppx_type_conv
backend which automatically prevents warning 32 on all values
generated by derivers:

$ ocamlfind ocamlopt -predicates ppx_driver -o ppx -linkpkg -package
ppx_fields_conv ppx_driver_runner.cmxa
$ ocamlfind ocamlc -pp ./ppx -package fieldslib -w A -c foo.mli
$ ocamlfind ocamlc -pp ./ppx -package fieldslib -w A -c foo.ml

On Tue, Nov 24, 2015 at 9:17 PM, Ashish Agarwal <agarwal1975@gmail.com> wrote:
> Thanks.
>
> On Tue, Nov 24, 2015 at 2:25 PM, octachron <octa@polychoron.fr> wrote:
>>
>>
>>> I think that's a typo in the manual: it should be [@@@warning "-32"]
>>> (with *three* at symbols).
>>> Regards,
>>> Leo
>>
>>
>> It is a typo in the manual – that have already been corrected in the dev
>> version of the manual.
>>
>> Regards,
>> octachron.
>>
>> --
>> 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
>
>



-- 
Jeremie

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-25 11:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-24 18:52 [Caml-list] how to apply an attribute on ppx output Ashish Agarwal
2015-11-24 19:02 ` Leo White
2015-11-24 19:25   ` octachron
2015-11-24 21:17     ` Ashish Agarwal
2015-11-25 11:33       ` Jeremie Dimino

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).