From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 38BF17EC6E for ; Sat, 18 Jan 2014 01:39:26 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jon@ffconsultancy.com) identity=pra; client-ip=84.93.230.244; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jon@ffconsultancy.com"; x-sender="jon@ffconsultancy.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jon@ffconsultancy.com) identity=mailfrom; client-ip=84.93.230.244; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jon@ffconsultancy.com"; x-sender="jon@ffconsultancy.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@avasout03.plus.net) identity=helo; client-ip=84.93.230.244; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jon@ffconsultancy.com"; x-sender="postmaster@avasout03.plus.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AukCAAfM2VJUXeb0lWdsb2JhbABZDoM1g1SlRHqRbIELFg4BAQEBBw0JCRIqgiUBAQEDAQgCGQRHEAcBAwIJEQQBAQMCCRoDAgIZIwkBCQgCBAESCwUCh18DCQwJp2aWQwOFYBeBKY1dBoIpQIFJBI8lii2LLogmPw X-IPAS-Result: AukCAAfM2VJUXeb0lWdsb2JhbABZDoM1g1SlRHqRbIELFg4BAQEBBw0JCRIqgiUBAQEDAQgCGQRHEAcBAwIJEQQBAQMCCRoDAgIZIwkBCQgCBAESCwUCh18DCQwJp2aWQwOFYBeBKY1dBoIpQIFJBI8lii2LLogmPw X-IronPort-AV: E=Sophos;i="4.95,677,1384297200"; d="scan'208";a="53787376" Received: from avasout03.plus.net ([84.93.230.244]) by mail2-smtp-roc.national.inria.fr with ESMTP; 18 Jan 2014 01:39:25 +0100 Received: from XPS ([91.125.229.6]) by avasout03 with smtp id FCfN1n00408vflX01CfQFS; Sat, 18 Jan 2014 00:39:24 +0000 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=VqIaXYGn c=1 sm=1 tr=0 a=YNNwqyIk8JSiwARLj6s6Lw==:117 a=YNNwqyIk8JSiwARLj6s6Lw==:17 a=0Bzu9jTXAAAA:8 a=f8j1qH8oLZQA:10 a=Xub9RBUEA-sA:10 a=Kvk-SOs2Z7YA:10 a=IkcTkHD0fZMA:10 a=r2vSxAw-AAAA:8 a=3NpDWv-ezvYA:10 a=ZOzjf2MOAAAA:8 a=CPTEj4YnAAAA:8 a=CjxXgO3LAAAA:8 a=RkHw4m7IlxyVtlHr5SsA:9 a=Hev6Ck5zRVMwEgyk:21 a=FyoRZOzixTCiEXM_:21 a=QEXdDO2ut3YA:10 a=rV3xvP3FSvkA:10 X-AUTH: jdh302:2500 Reply-To: From: "Jon Harrop" To: "'Jacques Garrigue'" , "'OCaML List Mailing'" References: <2112632769.281907.1389913202532.open-xchange@communicator.strato.de> <0290505B-A21A-4A05-A1C9-4C5F765DFEB5@math.nagoya-u.ac.jp> In-Reply-To: <0290505B-A21A-4A05-A1C9-4C5F765DFEB5@math.nagoya-u.ac.jp> Date: Sat, 18 Jan 2014 00:39:24 -0000 Organization: Flying Frog Consultancy Ltd. Message-ID: <02b301cf13e5$bdd11af0$397350d0$@ffconsultancy.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQFKLuDUCGYg/v2fnJQOy0RxKffuMwKqA4Dkm34dfMA= Content-Language: en-gb Subject: RE: [Caml-list] ocaml considered dangerous > By the way, there is now an implementation of Printf that avoids most of = the Obj.magic by using GADTs. It should be merged soon. Just curious: is that a drop-in replacement? Cheers, Jon. -----Original Message----- From: caml-list-request@inria.fr [mailto:caml-list-request@inria.fr] On Beh= alf Of Jacques Garrigue Sent: 17 January 2014 02:39 To: OCaML List Mailing Subject: Re: [Caml-list] ocaml considered dangerous Let me repost here the answer I sent to Jurgen on the developer=E2=80=99s l= ist. I wonder why he posted simultaneously to both lists. First remark, rather than posting such a (broken) link, it would be better = to file a report in the bug tracking system at http://caml.inria.fr/mantis/ Second, I=E2=80=99ve read your post (fortunately going to http://www.pfitz= enmaier.de/ let me access it), and this appears to be a misunderstanding of= the meaning of type annotations in OCaml. Namely, while type annotations in signatures are universally quantified (wh= ich is why =E2=80=98a list =3D forall =E2=80=98a. =E2=80=98a list is more g= eneral than int list, and your first example is not accepted), type annotat= ions in expressions are existentially quantified, i.e. the variables may be= instantiated, and as a result your second example is accepted (int list re= f is an instance of =E2=80=98a list ref). Same thing in your third example: the annotation =E2=80=98a list -> =E2=80= =98a just means that there should be some type a such that get_sum has type= a list -> a, and here that type is int. If you want annotations in expressions to be universally quantified, you mu= st be explicit: let get_sum : 'a. 'a list -> 'a =3D A.sum This one requires get_sum to be polymorphic, and will report an error. Of course changing line 28 in includecore.ml solves nothing, since this lin= e is correct from the beginning. Your examples with polymorphic variants are again a misunderstanding of how= typing works. Namely, in OCaml subtyping is always explicit. So in F1 you should write: let get_count :> [`A] list -> 'a =3D A.count (Note that in some case you a= lso need to give the original type of the expression for subtyping to work = properly. Here this is not needed because the target type is simple enough) For your frightening discoveries, the definition of ty0 is on line 499=E2= =80=A6 maybe too close to see. Last, the current implementation of Printf relies heavily on Obj.magic, whi= ch means that you cannot tell much about the typing by what you see inside = the implementation. To my best knowledge, the exported interface is type safe. By the way, there is now an implementation of Printf that avoids most of th= e Obj.magic by using GADTs. It should be merged soon. Finally I would suggest not to post such a blog before you discuss the prob= lems you encountered with somebody (not necessarily the developers, just so= mebody knowledgeable enough in OCaml) as this may confuse people in a usele= ss way. This would also have avoided you to part from OCaml for inexistent reasons.= .. Best regards, Jacques Garrigue -- 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=3D