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 645DE7EE9C for ; Fri, 25 Nov 2016 14:01:22 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=julien.blond@gmail.com; spf=Pass smtp.mailfrom=julien.blond@gmail.com; spf=None smtp.helo=postmaster@mail-yw0-f173.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of julien.blond@gmail.com) identity=pra; client-ip=209.85.161.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="julien.blond@gmail.com"; x-sender="julien.blond@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of julien.blond@gmail.com designates 209.85.161.173 as permitted sender) identity=mailfrom; client-ip=209.85.161.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="julien.blond@gmail.com"; x-sender="julien.blond@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-yw0-f173.google.com) identity=helo; client-ip=209.85.161.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="julien.blond@gmail.com"; x-sender="postmaster@mail-yw0-f173.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AM1MiLRMh4Hx7Tcs1hO8l6mtUPXoX/o7sNwtQ0KIM?= =?us-ascii?q?zox0Iv3zrarrMEGX3/hxlliBBdydsKMfzbGM+Py7EUU7or+5+EgYd5JNUxJXwe?= =?us-ascii?q?43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRp?= =?us-ascii?q?OOv1BpTSj8Oq3Oyu5pHfeQtFiT6zbL9oIhi6swrdu8YYjIB/Nqs/1xzFr2dSde?= =?us-ascii?q?9L321oP1WTnxj95se04pFu9jlbtuwi+cBdT6j0Zrw0QrNEAjsoNWA1/9DrugLY?= =?us-ascii?q?TQST/HscU34ZnQRODgPY8Rz1RJbxsi/9tupgxCmXOND9QL4oVTi+6apgVQTlgz?= =?us-ascii?q?kbOTEn7G7Xi9RwjKNFrxKnuxx/2JPfbIWMOPZjYq/RYdYWSGxcVchTSiNBGJux?= =?us-ascii?q?YIkBD+QBM+hWrJTzqUUSohalHwagGPnixyVUinPq36A31fkqHwHc3AwnGtIDqH?= =?us-ascii?q?DarMjxNKcTT++1yrTDwCjHb/NR3zfy9ZXDfxcjofGRWbJwcNTeyU81GwzeilWQ?= =?us-ascii?q?rorlMC6O2+QCtmiU9etgVea1h2E7rAFxpyGiy8ExgYfHgYIVz0rL9SR/wIstKt?= =?us-ascii?q?24SVJ7Yd65EJRLrS2VK4x2QsYkTmp1uyg60qULtYCncCUO0pgqxB7SZ+aaf4WJ?= =?us-ascii?q?/x7vTvudLDV2iX9jZbmxnQy98VK6xe35TsS00EhFri5CktTUs3ACzR3T6syeRv?= =?us-ascii?q?p98EatxS+D1w7O5uxGL004j6XbK5kmwr4/kpocr17PETPxmEXzlKOWd0Mk9fa0?= =?us-ascii?q?6+n/fLnqupuRO5V3hwz+KKgih82yDfkiPgQTXWWW9/yw1Lj58k34RLVKgOc2kq?= =?us-ascii?q?7csJ3CJ8Qbu6q5Aw5L3YYl8RqwFDOm0NMenXYaN19FdxeHgJLoO1HKOvz3EfC/?= =?us-ascii?q?g1G0nDdx2//GJqHhAonKLnXbjLjuZ7N960pFxAo3zNBf/I5UB6oaIPPzX0/xrM?= =?us-ascii?q?bXAgU4Mwyy2ebnCc9y2pkQWWKVUeelN/b+uEGJ6qoGJ+2XY5cN8GLxMfFg4fPx?= =?us-ascii?q?llc8lEMUZrWg1phRY3e9SKdIOUKcNFjxhtYMFy8gug04QKS+ikCGUDNVIXy2WK?= =?us-ascii?q?Qwzj4+AYOiS4zEQ9b+0/S6wC6nE8gONSh9AVeWHCKtLt3cVg=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BKAQCsNThYhq2hVdFeHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBgn8OAQEBAQF3gQIHgTSMCpcYlHSCCB0BBoV9AoIBBz8UAQEBAQE?= =?us-ascii?q?BAQEBAQESAQEBCAsLCR0wgjMaAYIaAQEBAwEBAg8RBBkBGx0BAwELBgMCBAcDC?= =?us-ascii?q?icDAgIhAQERAQUBCxEGExoIiDABAw8IDo4Rj1KBMj8yi1CBbBgFAR+DDQWDVwo?= =?us-ascii?q?ZJw1UgzYBAQEBAQEEAQEBAQEBAQEXAgEFEoYshFuCSIIugleCXQWaHzWBdoRSh?= =?us-ascii?q?miDVpAyiUCEMYJIEx6BEx6BLEARgmssIIFpPTSINwEBAQ?= X-IPAS-Result: =?us-ascii?q?A0BKAQCsNThYhq2hVdFeHAEBBAEBCgEBFwEBBAEBCgEBgn8?= =?us-ascii?q?OAQEBAQF3gQIHgTSMCpcYlHSCCB0BBoV9AoIBBz8UAQEBAQEBAQEBAQESAQEBC?= =?us-ascii?q?AsLCR0wgjMaAYIaAQEBAwEBAg8RBBkBGx0BAwELBgMCBAcDCicDAgIhAQERAQU?= =?us-ascii?q?BCxEGExoIiDABAw8IDo4Rj1KBMj8yi1CBbBgFAR+DDQWDVwoZJw1UgzYBAQEBA?= =?us-ascii?q?QEEAQEBAQEBAQEXAgEFEoYshFuCSIIugleCXQWaHzWBdoRShmiDVpAyiUCEMYJ?= =?us-ascii?q?IEx6BEx6BLEARgmssIIFpPTSINwEBAQ?= X-IronPort-AV: E=Sophos;i="5.31,547,1473112800"; d="scan'208,217";a="201704964" Received: from mail-yw0-f173.google.com ([209.85.161.173]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 25 Nov 2016 14:01:21 +0100 Received: by mail-yw0-f173.google.com with SMTP id i145so62662873ywg.2 for ; Fri, 25 Nov 2016 05:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=j+4rY8+ffFG3aRE62ObO3yt+g7ZO8J6hzDBsPzVE7Ig=; b=aA37En7vxa4MJvQBz0SdxETCLs6MEjHeCQOdE4Thv6X1os6zrJkbyPawUIkNuJwIz2 7wrMpaGK/jDDY6n4WxFES99PJ5E620NNWG+CisdRWbPPi0lAH7DuwegLWaosoWJhDeZX TyX+O0181dBBcZIUQwPVNxeAO1q8dGkCntnZkNNzda8Xsc46iQNJARpKHdjdDBiDS12m 68nNsbwp3Nc0RDLPG9SrjBuoN7tsGyMVPjZqMAKEf5TiOQozJ1PCwSRKVHgU8sgngpr1 SetMjalUKioxipqWwYCSlXZTK5I/vGxWKMfh5mPriJySKLEuPECyydraoJ7sFbubGS8b ZVwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=j+4rY8+ffFG3aRE62ObO3yt+g7ZO8J6hzDBsPzVE7Ig=; b=ErhY8djmnn49rVjt6I4tGq22opYtt/OKBq9MJxJt1qyBGT1dcX+3Dnyfk7DIWTMUGU 3xpyjqT4smcOELMO7Td3BRKOIRgd8t5w0DgPJi9AK7/JtFJ/1dLMbS6NyXgwOIVNVvHd ufo17hL9rIAM5ngl46sQOHK41+XJ+jGrRp22NDG92IT/2Z2nMKnA99KT7ixvVm0K7WVJ G2Ahp/Tdkb9M6yZafRhyx1TAj6REeIgambVGC2aUxv71B2los4WgLeprrkc9Ekg4ua41 GqASUD/kWTtrzQ6sxlMN1KffM9Dskb3LC7f4kvex3NHmWyTWt9f2bpkBMxwdi4xj8D5y VfEg== X-Gm-Message-State: AKaTC02lhdULCfZEzhmsMoKx3OHmntTa9bDCmFR87t1yPRMGhRXTho7upUbbid2Ut9D70ATYx/AajJXQxWRCUg== X-Received: by 10.129.0.67 with SMTP id 64mr9424631ywa.61.1480078878840; Fri, 25 Nov 2016 05:01:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.80.68 with HTTP; Fri, 25 Nov 2016 05:01:18 -0800 (PST) In-Reply-To: References: From: Julien Blond Date: Fri, 25 Nov 2016 14:01:18 +0100 Message-ID: To: David Allsopp Cc: OCaml mailing-list Content-Type: multipart/alternative; boundary=001a1140b6c4d04ed905421fb735 Subject: Re: [Caml-list] Empty polymorphic variant set --001a1140b6c4d04ed905421fb735 Content-Type: text/plain; charset=UTF-8 Yes, i knew the variant constructor but, somehow i didn't realize i was precisely using it for my mind was focused on the polymorphic variant list :) In fact, i wondered if a generic result type like this type ('a, 'b) result = Ok of 'a | Error of 'b that we can see in several library could be used to specify a "safe" result which could have type something like ('a, []) result. One could encode 'b as some error list at type level but it needs some complicated type management and i'm targeting OCaml beginners for which i just want them to be careful about non nominal results. 2016-11-25 12:22 GMT+01:00 David Allsopp : > Julien Blond wrote: > > 2016-11-25 9:39 GMT+01:00 Julien Blond : > > Hi, > > Let's try something : > > $ ocaml > > OCaml version 4.03.0 > > > > # let _ : [] list = [];; > > Characters 9-10: > > let _ : [] list = [];; > > Error: Syntax error > > # type empty = [];; > > type empty = [] > > # let _ : empty list = [];; > > - : empty list = [] > > # > > > > Does anyone know if there is a reason to forbid the empty polymorphic > variant > > set in type expressions or if it's a bug ? > > As you've observed, [] is a variant constructor since 4.03.0 - see GPR#234 > (https://github.com/ocaml/ocaml/pull/234). The GPR contains references > and comments as to the motivation for this. > > What's your desired use for the type of the non-extensible empty > polymorphic variant? > > Possibly related, you can define a general type for a list of polymorphic > variants: > > let (empty : [> ] list) = [] > > or > > let (length : [> ] list -> int) = List.length;; > length [`Foo; `Bar];; > length [42];; > > if that's what you were after? > > > David > --001a1140b6c4d04ed905421fb735 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Yes, i knew the variant constructor but, so= mehow i didn't realize i was precisely using it for my mind was focused= on the polymorphic variant list :)

In fact, i wondered if a g= eneric result type like this

type ('a, 'b) result =3D= Ok of 'a | Error of 'b

that we can see in sever= al library could be used to specify a "safe" result which could h= ave type something like ('a, []) result. One could encode 'b as som= e error list at type level but it needs some complicated type management an= d i'm targeting OCaml beginners for which i just want them to be carefu= l about non nominal results.


2016-11-25 12:22 GMT+01:00 David Allsopp <dr= a-news@metastack.com>:
Juli= en Blond wrote:
> 2016-11-25 9:39 GMT+01:00 Julien Blond <mailto:julien.blond@gmail.com>:=
> Hi,
> Let's try something :
> $ ocaml
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 OCaml version 4.03.0
>
> # let _ : [] list =3D [];;
> Characters 9-10:
>=C2=A0 let _ : [] list =3D [];;
> Error: Syntax error
> # type empty =3D [];;
> type empty =3D []
> # let _ : empty list =3D [];;
> - : empty list =3D []
> #
>
> Does anyone know if there is a reason to forbid the empty polymorphic = variant
> set in type expressions or if it's a bug ?

As you've observed, [] is a variant constructor since 4.03.0 - s= ee GPR#234 (https://github.com/ocaml/ocaml/pull/234)= . The GPR contains references and comments as to the motivation for this.
What's your desired use for the type of the non-extensible empty polymo= rphic variant?

Possibly related, you can define a general type for a list of polymorphic v= ariants:

let (empty : [> ] list) =3D []

or

let (length : [> ] list -> int) =3D List.length;;
length [`Foo; `Bar];;
length [42];;

if that's what you were after?


David

--001a1140b6c4d04ed905421fb735--