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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id E595A7EE79 for ; Mon, 16 May 2016 20:53:26 +0200 (CEST) IronPort-PHdr: 9a23:LxyoWBI+vbDU2UxO49mcpTZWNBhigK39O0sv0rFitYgVKP3xwZ3uMQTl6Ol3ixeRBMOAu6MC0bSd6vq8EUU7or+/81k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i760zceF13FOBZvIaytQ8iJ35Xxjb75osePKyxzxxODIppKZC2sqgvQssREyaBDEY0WjiXzn31TZu5NznlpL1/A1zz158O34YIxu38I46Fp34d6XK77Z6U1S6BDRHRjajhtpZ6jiR6WfAyT735UeGwMlB1ZS1zU6w3zW534qC39p8Jy3SCbOYv9SrViHXyN4r1nACT0jyMfMjc/9imDi8p+i4pUrQit4gdjxIrMZYiTMrxyc/WOU8kdQD9uRMteUDZQSqa1a4YED+NJaeldpo3wrFsHhRS7DAioQujoz2kb1TfNwaQm3rF5Qkn91ws6EodL6SyMoQ== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=gmalecha@gmail.com; spf=Pass smtp.mailfrom=gmalecha@gmail.com; spf=None smtp.helo=postmaster@mail-oi0-f42.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gmalecha@gmail.com) identity=pra; client-ip=209.85.218.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gmalecha@gmail.com"; x-sender="gmalecha@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of gmalecha@gmail.com designates 209.85.218.42 as permitted sender) identity=mailfrom; client-ip=209.85.218.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gmalecha@gmail.com"; x-sender="gmalecha@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-oi0-f42.google.com) identity=helo; client-ip=209.85.218.42; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gmalecha@gmail.com"; x-sender="postmaster@mail-oi0-f42.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BNAgAzFjpXjyraVdFchAx+shWCYYUFgXYkhW0CgS45EwEBAQEBAQEBEQEBAQEHCwsJIS9BEgGBWYIVAQEBAwESEQQZARQHDw4BAwELBgMCBAcNKgICIQEBEQEFARwGARIJGYdyAQMPCA6Re49CgTE+MYs7gWqCWAWHVwoZJw1Sg1UBAQEBAQEBAQEBAQEBAQEBAQEBAQEUAgYQhR14hE2CQ4IIIYJTglkFh36PeDGFfoYnA4F2gjeMYodchicwgQ4PEwOCNh6BVTwyAYUyglMBAQE X-IPAS-Result: A0BNAgAzFjpXjyraVdFchAx+shWCYYUFgXYkhW0CgS45EwEBAQEBAQEBEQEBAQEHCwsJIS9BEgGBWYIVAQEBAwESEQQZARQHDw4BAwELBgMCBAcNKgICIQEBEQEFARwGARIJGYdyAQMPCA6Re49CgTE+MYs7gWqCWAWHVwoZJw1Sg1UBAQEBAQEBAQEBAQEBAQEBAQEBAQEUAgYQhR14hE2CQ4IIIYJTglkFh36PeDGFfoYnA4F2gjeMYodchicwgQ4PEwOCNh6BVTwyAYUyglMBAQE X-IronPort-AV: E=Sophos;i="5.26,627,1459807200"; d="scan'208,217";a="177956725" Received: from mail-oi0-f42.google.com ([209.85.218.42]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 16 May 2016 20:53:25 +0200 Received: by mail-oi0-f42.google.com with SMTP id x19so282301972oix.2 for ; Mon, 16 May 2016 11:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OxQL9xV/gZF/Xi4D4kLzU5iHK8fcmHICLeTJ9SHjkpg=; b=NyZvsbtYwopJyoBQiNeqEC79a1nqNidpcvHHUPybMWQwYq9sfQeKP8U3AeIyK4pH2p bsP2dsmV6ClUKY9ncDxGA41ADDl7vX492S8BAbKzfHm3VBaliOnGh0Maw6VHH8E8H2Dn x0XXuNSGH5HYkdpP2NFMXrmLg4t+T8oK1YBJ/k2Q99qmEVPGiqDlYJIL75RZqPy4+5Jj 3xHvTlqyEnNtY9LqhlfxNWzN4mKS8KqRbdmorqt4qAJX0fmSGA7OmxDEWJgyN3ua/ikX 3aUhkJpUZzYvuyIhmOc6ZjEgzD5jHM80Zkesfol+kEGaDM+VQ/7OB0yrl24lQKrCKEEE VGFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OxQL9xV/gZF/Xi4D4kLzU5iHK8fcmHICLeTJ9SHjkpg=; b=PIwLaSXV1dsBK+uflHI8naln0Oz6LJ3YZDFxj2D+wTX+CxeW+QbXSmXIQnGGbVuNjF zqOvRPPkQKBFk+EAKkoWsHQzsn0S9WuZyDqzXcKwFs901SrOL1k5jNXrce+FYYaACGq/ Ton6vKVppn0tPivCUDHwTxwVw1cTrbnAcp+AR+gZDjmryY0tActa/ZNXT8YgHFFVwkr8 RqA+XCHla3/lmAj1IqchqnqePbGDSKSIHHgMuBRlb9AooC1S8mxIlav9OUu+X9PJIIDK gCg7akfnKKmzpJz1HnFvV6nGGj7KgxUXdRiygv/+YBsCyoaFSuJ98rQVEn2jebW9iSfS x6IA== X-Gm-Message-State: AOPr4FVbGHpPJg46Q50masZuqsgsW2FDPKFKun/QMW4Y7Au2x7i7bA5W4OUF78fhlUX9y1cWlbJ7XQmudoU1/w== X-Received: by 10.157.9.227 with SMTP id 32mr5239199otz.132.1463424804367; Mon, 16 May 2016 11:53:24 -0700 (PDT) MIME-Version: 1.0 References: <1463412482-sup-8520@hennequin-xps> <1463417600-sup-2106@hennequin-xps> <1463419945.3467.32.camel@e130.lan.sumadev.de> In-Reply-To: From: Gregory Malecha Date: Mon, 16 May 2016 18:53:14 +0000 Message-ID: To: Yotam Barnoy , Gerd Stolpmann Cc: Guillaume Hennequin , caml users Content-Type: multipart/alternative; boundary=001a113d1bfa9eb3c60532fa235c Subject: Re: [Caml-list] issue with polymorphism --001a113d1bfa9eb3c60532fa235c Content-Type: text/plain; charset=UTF-8 There may other reasons as well, e.g. performance and compilability, but the main reason that I know is that inferring these types is difficult (undecideable in general). For a point of comparison, GHC supports types like this, but only when they are explicitly written. On Mon, May 16, 2016, 11:50 AM Yotam Barnoy wrote: > Paging the type experts -- is there a concrete reason why we disallow > writing this type directly? > > On Mon, May 16, 2016 at 1:32 PM, Gerd Stolpmann > wrote: > >> Am Montag, den 16.05.2016, 17:55 +0100 schrieb Guillaume Hennequin: >> > Thanks all for your prompt answers; >> > >> > > See the FAQ entry, "How to write a function with polymorphic >> arguments?" >> > > >> https://ocaml.org/learn/faq.html#Howtowriteafunctionwithpolymorphicarguments >> > >> > this page explains how to do it with records or objects, but ends with a >> > mysterious "FIXME: a direct way now exists". Does anyone know what this >> might >> > refer to? >> >> What you would need is >> >> let print_both : ('a . 'a -> 'a) -> unit = ... >> >> i.e. the scope of the quantifier is restricted to the first argument. >> This doesn't exist to my knowledge. Maybe it was part of some dev >> version? >> >> Gerd >> -- >> ------------------------------------------------------------ >> Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de >> My OCaml site: http://www.camlcity.org >> Contact details: http://www.camlcity.org/contact.html >> Company homepage: http://www.gerd-stolpmann.de >> ------------------------------------------------------------ >> >> > -- - gregory malecha gmalecha.github.io --001a113d1bfa9eb3c60532fa235c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

There may other reasons as well, e.g. performance and compil= ability, but the main reason that I know is that inferring these types is d= ifficult (undecideable in general). For a point of comparison, GHC supports= types like this, but only when they are explicitly written.


On Mon, May 16, 2016, 11:50= AM Yotam Barnoy <yotambarnoy@g= mail.com> wrote:
Paging the type experts -- is there a concrete reason why we disallow= writing this type directly?

On Mon, May 16, 2016 at 1:32 PM, Gerd Stolpmann <in= fo@gerd-stolpmann.de> wrote:
ht= tps://ocaml.org/learn/faq.html#Howtowriteafunctionwithpolymorphicarguments<= /a>
>
> this page explains how to do it with records or objects, but ends with= a
> mysterious "FIXME: a direct way now exists". Does anyone kno= w what this might
> refer to?

What you would need is

let print_both : ('a . 'a -> 'a) -> unit =3D ...

i.e. the scope of the quantifier is restricted to the first argument.
This doesn't exist to my knowledge. Maybe it was part of some dev
version?

Gerd
--
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany=C2=A0 =C2=A0 gerd@gerd-stolpmann.de
My OCaml site:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 http://www.camlcity.org<= br> Contact details:=C2=A0 =C2=A0 =C2=A0 =C2=A0 http://www.camlcity.= org/contact.html
Company homepage:=C2=A0 =C2=A0 =C2=A0 =C2=A0http://www.gerd-stolpmann.de=
------------------------------------------------------------


--

- gregory m= alecha
=C2=A0 gmalecha.github.io

--001a113d1bfa9eb3c60532fa235c--