From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 00F097EFCD for ; Mon, 13 Oct 2014 15:49:23 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jun.furuse@gmail.com) identity=pra; client-ip=74.125.82.47; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jun.furuse@gmail.com"; x-sender="jun.furuse@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of jun.furuse@gmail.com designates 74.125.82.47 as permitted sender) identity=mailfrom; client-ip=74.125.82.47; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jun.furuse@gmail.com"; x-sender="jun.furuse@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wg0-f47.google.com) identity=helo; client-ip=74.125.82.47; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jun.furuse@gmail.com"; x-sender="postmaster@mail-wg0-f47.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlwBAOfXO1RKfVIvlGdsb2JhbABbg2FYBMsjiGMHFgERAQEBAQcLCwkSMIQbFRkBGx4DEhBdAREBBQEiGxqIBwEDEQ2fd4Mdbo0igxCIRgoZJw1nhgImAQEEDo9fhSoFi1yHJIM7hxCMXIdDGCmFNTAvgQaBRAEBAQ X-IPAS-Result: AlwBAOfXO1RKfVIvlGdsb2JhbABbg2FYBMsjiGMHFgERAQEBAQcLCwkSMIQbFRkBGx4DEhBdAREBBQEiGxqIBwEDEQ2fd4Mdbo0igxCIRgoZJw1nhgImAQEEDo9fhSoFi1yHJIM7hxCMXIdDGCmFNTAvgQaBRAEBAQ X-IronPort-AV: E=Sophos;i="5.04,710,1406584800"; d="scan'208";a="83069466" Received: from mail-wg0-f47.google.com ([74.125.82.47]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 13 Oct 2014 15:49:23 +0200 Received: by mail-wg0-f47.google.com with SMTP id x13so8593224wgg.6 for ; Mon, 13 Oct 2014 06:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=oS6JZqshY1DrLANjj2PXFefrUNhoARO2GgiYVXal640=; b=IF6U/Nca2LSq/E8D8YCN14PNs1ewKSvz8TpgTVJWQwHZtwgPfquvlK/9yEw+MUsYvc 3qw13IFG+5CXmD9uqghFRNJtW3IHBNjsrrrTqoHY5FSVNSzHfSjGGxcfDzUmPttdo88E ue2VbluGoLksXVgkVtYUWHoZK9Ckfqil2slQEksO69yFqa/laaw3vgkAOFScQ8vn6DPP Anp+B7MXdjo8Zj7eeucDuIRMZ2we2ErwQG8EnoPq354GH042a5x6w6LsV9gAgyEasiMh bEU5i5M6vqfyJzkaXFnd9MzJVoANzWrFcfrXTnroStStPXJOV+2tVVnlF1QsrhnGI4rl 9rVQ== MIME-Version: 1.0 X-Received: by 10.194.186.196 with SMTP id fm4mr2906526wjc.42.1413208162565; Mon, 13 Oct 2014 06:49:22 -0700 (PDT) Received: by 10.194.164.69 with HTTP; Mon, 13 Oct 2014 06:49:22 -0700 (PDT) Date: Mon, 13 Oct 2014 21:49:22 +0800 Message-ID: From: Jun Furuse To: caml-list Content-Type: text/plain; charset=ISO-8859-1 Subject: [Caml-list] [ANN] ppx_overload : ppx for user definable SML style overloading Hi, I have OPAM-released ppx_overload, a ppx for user definable SML style overloading. For example you can overload (+) and (+.) to Plus.(+) as follows: module Plus = struct external (+) : 'a -> 'a -> 'a = "%OVERLOADED" module Int = struct let (+) = Pervasives.(+) end module Float = struct let (+) = Pervasives.(+.) end end Then Plus.(+) works for int and float additions! It works as follows: * Declaration of overloaded values by external "%OVERLOADED" * List the instances with the same name in its sub modules. * The uses of overloaded values are resolved to one of their instances at typing phase. The overloading of ppx_overload is pretty limited: you cannot derive overloading by using overloaded values polymorphicially. You cannot define overloaded double with the overloaded Plus.(+). But still it is a very interesting ppx example to combine with the OCaml typing. ppx_overload is now available in OPAM. More detailed explanation how it works is explained in the project page: https://bitbucket.org/camlspotter/compiler-libs-hack . Enjoy! Thanks Jun