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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 7D47A7FBFE for ; Fri, 23 Jan 2015 09:03:37 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=pra; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=mailfrom; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mailhost.math.nagoya-u.ac.jp) identity=helo; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="postmaster@mailhost.math.nagoya-u.ac.jp"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An0FAFL/wVSFBoIFXWdsb2JhbABag1hYxk6FNjkCgVUBAQEBAQYYCwocLoQNAQU6BgMBNQEBDgsYLkMUBog+Dr0nhVgCi1SEIAEBAQEBAQEBAQEBAQEBAQEBAQEBARABAgSPRTMHgxaBE4oEiDGDWIF3gSSJIYdwhB8vMQWCPgEBAQ X-IPAS-Result: An0FAFL/wVSFBoIFXWdsb2JhbABag1hYxk6FNjkCgVUBAQEBAQYYCwocLoQNAQU6BgMBNQEBDgsYLkMUBog+Dr0nhVgCi1SEIAEBAQEBAQEBAQEBAQEBAQEBAQEBARABAgSPRTMHgxaBE4oEiDGDWIF3gSSJIYdwhB8vMQWCPgEBAQ X-IronPort-AV: E=Sophos;i="5.09,453,1418079600"; d="scan'208";a="118269800" Received: from rabbit.math.nagoya-u.ac.jp (HELO mailhost.math.nagoya-u.ac.jp) ([133.6.130.5]) by mail2-smtp-roc.national.inria.fr with ESMTP; 23 Jan 2015 09:03:34 +0100 Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id E3EB7658D; Fri, 23 Jan 2015 17:03:31 +0900 (JST) Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 9ECA3416B; Fri, 23 Jan 2015 17:03:31 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=math.nagoya-u.ac.jp; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=alpha; bh=WD22NH+vaamWujR17dYipfqu7qk=; b=doERCtvkp1hEoLhpSGDX2isWbE/t jlfJsFGipRfBUAqhBWWQ6hPVNa0KRn9vrGJpwc97lJvGeoDYCuWPCoyIpDA2eOYO klWbMZTQvhul0LArDu5vi+inkD1nru297drnSdV074EwLS2pS3Q4SUh27rLWLW6g 4ttkFcWsP6bPD0I= DomainKey-Signature: a=rsa-sha1; h=Received:Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=eu990nK0pQ6/yOXo7KYaYk9Gr0Hdx8PDp3hV1WkZlAqtxrwYPCzObwePr0TjDjJJZ0PyG2ZgcskK+XO2/MPbDYTkHnPeC6DBkMWeKCuoEzi9cGtFm+/7bb4OYIygyEB1ihQj1mlS/YsbDbn9qdmk9LME6EIFSq8FxbBfSJXtHUQ=; c=nofws; d=math.nagoya-u.ac.jp; q=dns; s=alpha Received: from garrigue-mini.math.nagoya-u.ac.jp (garrigue-mini.math.nagoya-u.ac.jp [172.16.30.37]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 59EB4416A; Fri, 23 Jan 2015 17:03:31 +0900 (JST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) From: Jacques Garrigue In-Reply-To: Date: Fri, 23 Jan 2015 17:03:31 +0900 Cc: Mailing List OCaml Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Jordan W X-Mailer: Apple Mail (2.1993) Subject: Re: [Caml-list] Explicit Arity with Polymorphic Variants The answer is simple: polymorphic variants can only accept one argument (which may of course be a tuple). The other behavior would have required a specific syntax for multi-parameter polymorphic variants, since there is no information associated to the constructor for them. Jacques Garrigue On 2015/01/23 15:53, Jordan W wrote: >=20 > The OCaml compiler allows distinguishing between variants that accept a s= ingle tuple and variant types that accept several parameters. What looks li= ke a variant type accepting a tuple, is actually the later: >=20 > type x =3D TwoSeparateArguments of int * int > let tuple =3D (10,10) > let thisWontWork =3D TwoSeparateArguments tuple;; > >> Error: The constructor TwoSeparateArguments expects 2 argument(s), = but is applie= d here to 1 argument(s) >=20 > (* Notice the extra parens around the two ints *) > type x =3D OneArgumentThatIsATuple of (int * int) > let thisActuallyWorks =3D OneArgumentThatIsATuple tuple >=20 > The extra parens distinguish at type definition time which of the two is = intended. >=20 > But OCaml does some automatic massaging of the data that you supply to co= nstructor values. > let _ =3D OneArgumentThatIsATuple (4, 5) > let _ =3D TwoSeparateArguments (4, 5) >=20 > No extra parens are required in this case. But OCaml does give you the ab= ility to annotate patterns and expressions with an "explicit_arity" attribu= te which allows syntactic distinction between supplying two separate parame= ters vs. one that happens to be a tuple. This is important for other parser= extensions that wish to treat the two distinctly. What OCaml allows (expli= cit_arity attribute) works well enough. >=20 > The only problem is that there doesn't seem to be a way to utilize the sa= me explicit_arity attributes with polymorphic variants. Such attributes are= not acknowledged by the type system. Is this intended? >=20 > Taking a quick look at typecore.ml, explicit_arity appears to be acknowle= dged on standard constructors but not polymorphic variants. > https://github.com/ocaml/ocaml/blob/6e85c2d956c8fd5b45acd70a27586e44bb3a3= 119/typing/typecore.ml >=20 > It seems these should be brought to consistency. I will file a mantis iss= ue unless anyone believes this is intended. >=20 > Thank you in advance. >=20 > Jordan >=20 >=20