From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id E22877ED5C for ; Sun, 5 Aug 2012 04:47:11 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of cedilla@gmail.com) identity=pra; client-ip=209.85.160.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="cedilla@gmail.com"; x-sender="cedilla@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of cedilla@gmail.com designates 209.85.160.54 as permitted sender) identity=mailfrom; client-ip=209.85.160.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="cedilla@gmail.com"; x-sender="cedilla@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-pb0-f54.google.com) identity=helo; client-ip=209.85.160.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="cedilla@gmail.com"; x-sender="postmaster@mail-pb0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AusCABfdHVDRVaA2jWdsb2JhbABFhXuzOwgiAQEBAQcLFBIGI4IgAQEBAwESAg8EGQEbHQEDAQsGBQs3AgICHwEBEQEFARwGEx4Eh1sBAwYGnDMJA4tUT4JxhBoKGScNV4hxAQUMildnhXKBEgOITYYMgSCDfYFTiwmDJj6EHoE2BQ X-IronPort-AV: E=Sophos;i="4.77,714,1336341600"; d="ml'?scan'208";a="169097102" Received: from mail-pb0-f54.google.com ([209.85.160.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Aug 2012 04:47:10 +0200 Received: by pbbro2 with SMTP id ro2so4398571pbb.27 for ; Sat, 04 Aug 2012 19:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=vZY4ktVhzxJ04ITMy1a1pr8d2mwzQW4X728MXT5UhFk=; b=Z+YsizfUIE9aO9rlAgxdhpd723HX/aQw1riXNZbCW8fgt97DfQlzHJShXqk2Hcd3EN XCWoj9mhGtuC5pwz+gTcD8OrOCbGZyfkV9EzbmDMRpcgXkxDbIqmxuTgnXXwzjg8Y53H oSi07U5crkUgXb7bYEQll0fy9DlIjuh2kHOkb4X+bzzTgiFrXtQQD87UzaxO7TTqxdy9 7OwVhkQqFhMXa33UDA9ogx9uIXCiiNkzxkxyLdx1v1DPj4XhAQ4HH9yzrhOwe7Hvgx7X K59c52NfHZLdC5cZphswHfzSE7Tq25ysNsOjuZmCxvk8PxzugwRaY5DTvgl+zSLw8mPE 3rNQ== MIME-Version: 1.0 Received: by 10.68.134.161 with SMTP id pl1mr8628268pbb.29.1344134829282; Sat, 04 Aug 2012 19:47:09 -0700 (PDT) Received: by 10.142.173.15 with HTTP; Sat, 4 Aug 2012 19:47:09 -0700 (PDT) In-Reply-To: References: Date: Sat, 4 Aug 2012 19:47:09 -0700 Message-ID: From: Reed Wilson To: Gabriel Scherer Cc: caml-list@inria.fr Content-Type: multipart/mixed; boundary=047d7b10cec30793e104c67bc75b X-Validation-by: cedilla@gmail.com Subject: Re: [Caml-list] creating GADTs --047d7b10cec30793e104c67bc75b Content-Type: multipart/alternative; boundary=047d7b10cec30793d604c67bc759 --047d7b10cec30793d604c67bc759 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Again, thanks for all the assistance. The warning and Match_failure in your post are what I expected in my program, but I didn't receive either. The print_samplerate function just returns the wrong answer. I tested it on 4.00.0 Win 32- and 64-bit, Linux 64-bit, and 4.01.0+dev6_2012-07-30 Linux 64-bit. Even in the toplevel it runs fine: # let print_samplerate : type id chan. (id,chan) frame_t -> unit =3D functi= on | {header_id =3D MPEG1; header_samplerate =3D S48000} -> Printf.printf "M1_S48000\n" | {header_id =3D MPEG1; header_samplerate =3D S44100} -> Printf.printf "M1_S44100\n" | {header_id =3D MPEG2; header_samplerate =3D S24000} -> Printf.printf "M2_S24000\n" | {header_id =3D MPEG2; header_samplerate =3D S22050} -> Printf.printf "M2_S22050\n" ;; val print_samplerate : ('id, 'chan) frame_t -> unit =3D # let test_frame =3D frame_of_sr_id_chan (samplerate_of_int 3) (mpeg_of_int 0, channel_mode_of_int 0);; val test_frame : (mpeg_tag_t, channel_tag_t) frame_t =3D {header_id =3D MPEG1; header_crc =3D true; header_samplerate =3D S22050; header_channel_mode =3D Channel_mono; side_bits =3D Bits_1_mono } # print_samplerate test_frame;; M1_S44100 - : unit =3D () The exact file I ran is attached (hopefully -- are attachments good on this list?), and it prints "M1_S44100" with no errors or warnings on all my computers, even though I think it should give an exception or otherwise fail. Does it do something different on yours? Thanks, Reed On Sat, Aug 4, 2012 at 4:45 PM, Gabriel Scherer wrote: > > I was happy to notice that this did not complain about being > > incomplete, correctly seeing that the samplerates can only be used > > with a matching header_id; > > > > However, if I then I make an invalid frame using the *_of_int functions: > > > > let test_frame =3D frame_of_sr_id_chan (samplerate_of_int 3) > > (mpeg_of_int 0, channel_mode_of_int 0);; > > print_samplerate test_frame;; > > Here is what I observe on my machine: > > # let print_samplerate : type id chan. (id,chan) frame_t -> unit =3D func= tion > [...] > Warning 8: this pattern-matching is not exhaustive. > Here is an example of a value that is not matched: > {header_id=3DMPEG2; header_samplerate=3DS48000} > > # let test_frame =3D frame_of_sr_id_chan (samplerate_of_int 3) > (mpeg_of_int 0, channel_mode_of_int 0);; > val test_frame : (mpeg_tag_t, channel_tag_t) frame_t =3D > {header_id =3D MPEG1; header_crc =3D true; header_samplerate =3D S22050; > header_channel_mode =3D Channel_mono; side_bits =3D Bits_1_mono } > > # print_samplerate test_frame;; > Exception: Match_failure ("//toplevel//", 43, -733). > --=20 =C3=A7 --047d7b10cec30793d604c67bc759 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Again, thanks for all the assistance.

The warning and Ma= tch_failure in your post are what I expected in my program, but I didn'= t receive either. The print_samplerate function just returns the wrong answ= er. I tested it on 4.00.0 Win 32- and 64-bit, Linux 64-bit, and 4.01.0+dev6= _2012-07-30 Linux 64-bit.

Even in the toplevel it runs fine:

<= /div>
# let print_samplerate : type id chan. (id,chan) frame_t -&g= t; unit =3D function
| {header_id =3D MPEG1; header_samplerate = =3D S48000} -> Printf.printf "M1_S48000\n"
| {header_id =3D MPEG1; header_samplerate =3D S44100} -> Printf.pri= ntf "M1_S44100\n"
| {header_id =3D MPEG2; header_sample= rate =3D S24000} -> Printf.printf "M2_S24000\n"
| {h= eader_id =3D MPEG2; header_samplerate =3D S22050} -> Printf.printf "= ;M2_S22050\n"
;;
val print_samplerate : ('id, 'chan) frame_t ->= unit =3D <fun>

# let test_frame =3D f= rame_of_sr_id_chan (samplerate_of_int 3) (mpeg_of_int 0, channel_mode_of_in= t 0);;
val test_frame : (mpeg_tag_t, channel_tag_t) frame_t =3D
=C2= =A0 {header_id =3D MPEG1; header_crc =3D true; header_samplerate =3D S22050= ;
=C2=A0 =C2=A0header_channel_mode =3D Channel_mono; side_bits = =3D Bits_1_mono <abstr>}

# print_samplerate test_frame;;
M1_S44100
- : unit =3D ()


The ex= act file I ran is attached (hopefully -- are attachments good on this list?= ), and it prints "M1_S44100" with no errors or warnings on all my= computers, even though I think it should give an exception or otherwise fa= il. Does it do something different on yours?

Thanks,
Reed

On Sat, Aug 4, 2012 at 4:45 PM, Gabriel Scherer <gabriel.scherer= @gmail.com> wrote:
> I was happy to notice= that this did not complain about being
> incomplete, correctly seeing that the samplerates can only be used
> with a matching header_id;
>
> However, if I then I make an invalid frame using the *_of_int function= s:
>
> let test_frame =3D frame_of_sr_id_chan (samplerate_of_int 3)
> (mpeg_of_int 0, channel_mode_of_int 0);;
> print_samplerate test_frame;;

Here is what I observe on my machine:

# let print_samplerate : type id chan. (id,chan) frame_t -> unit =3D fun= ction
[...]
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
{header_id=3DMPEG2; header_samplerate=3DS48000}

# let test_frame =3D frame_of_sr_id_chan (samplerate_of_int 3)
(mpeg_of_int 0, channel_mode_of_int 0);;
=C2=A0 val test_frame : (mpeg_tag_t, channel_tag_t) frame_t =3D
=C2=A0 {header_id =3D MPEG1; header_crc =3D true; header_samplerate =3D S22= 050;
=C2=A0 =C2=A0header_channel_mode =3D Channel_mono; side_bits =3D Bits_1_mon= o <abstr>}

# print_samplerate test_frame;;
Exception: Match_failure ("//toplevel//", 43, -733).

--
=C3=A7
--047d7b10cec30793d604c67bc759-- --047d7b10cec30793e104c67bc75b Content-Type: application/octet-stream; name="typetest2.ml" Content-Disposition: attachment; filename="typetest2.ml" Content-Transfer-Encoding: base64 X-Attachment-Id: f_h5hilpa10 dHlwZSBtcGVnX3RhZ190ID0gWyBgTXBlZzEgfCBgTXBlZzIgXTs7DQoNCnR5 cGUgXyBtcGVnX3QgPQ0KfCBNUEVHMSA6IFs8IG1wZWdfdGFnX3QgPiBgTXBl ZzFdIG1wZWdfdA0KfCBNUEVHMiA6IFs8IG1wZWdfdGFnX3QgPiBgTXBlZzJd IG1wZWdfdA0KOzsNCg0KdHlwZSBfIHNhbXBsZXJhdGVfdCA9DQp8IFM0ODAw MCA6IFs8IG1wZWdfdGFnX3QgPiBgTXBlZzFdIHNhbXBsZXJhdGVfdA0KfCBT NDQxMDAgOiBbPCBtcGVnX3RhZ190ID4gYE1wZWcxXSBzYW1wbGVyYXRlX3QN CnwgUzI0MDAwIDogWzwgbXBlZ190YWdfdCA+IGBNcGVnMl0gc2FtcGxlcmF0 ZV90DQp8IFMyMjA1MCA6IFs8IG1wZWdfdGFnX3QgPiBgTXBlZzJdIHNhbXBs ZXJhdGVfdA0KOzsNCg0KdHlwZSBjaGFubmVsX3RhZ190ID0gW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