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 F06317EEB4 for ; Fri, 1 Feb 2013 21:39:53 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of lukstafi@gmail.com) identity=pra; client-ip=209.85.128.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lukstafi@gmail.com"; x-sender="lukstafi@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of lukstafi@gmail.com designates 209.85.128.174 as permitted sender) identity=mailfrom; client-ip=209.85.128.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lukstafi@gmail.com"; x-sender="lukstafi@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ve0-f174.google.com) identity=helo; client-ip=209.85.128.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lukstafi@gmail.com"; x-sender="postmaster@mail-ve0-f174.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiUCAEwnDFHRVYCum2dsb2JhbABFvycIFg4BAQEBAQgJFBQngh4BAQVAARsdAQMMBgULDS4hAQERAQUBHAYTh34BAw+kT4w0gnuEYgoZJw1ZiHcBBQyMDYU1A5RAgVeLPoMxFimEHw X-IPAS-Result: AiUCAEwnDFHRVYCum2dsb2JhbABFvycIFg4BAQEBAQgJFBQngh4BAQVAARsdAQMMBgULDS4hAQERAQUBHAYTh34BAw+kT4w0gnuEYgoZJw1ZiHcBBQyMDYU1A5RAgVeLPoMxFimEHw X-IronPort-AV: E=Sophos;i="4.84,579,1355094000"; d="scan'208";a="1054415" Received: from mail-ve0-f174.google.com ([209.85.128.174]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 01 Feb 2013 21:39:53 +0100 Received: by mail-ve0-f174.google.com with SMTP id pb11so728709veb.5 for ; Fri, 01 Feb 2013 12:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=R0xARUCldMaJfqj+ppcoUSlVi3cQ9HKi7DY9imVG/m0=; b=kysra65PBezXuMYJA1VjzR2s4kzsuv9OKw3iH2b7pUMs1V6+/qRDS5z2+yXCZkVGn6 khf7X/l+ZXvcFg/ztW073p64mTTkcPlNeVN+frxikAj786bbvgBN7aODV0sgrDMqvaRh ukUm74cEN7lndj6iqpq38hpFa7TNDsxcoq0ZWh2u49KRiyuYBuYhraeR+AcXTQ6DPsVa 1S6h2eKb7RR7JtCXzrL4clGRsDBJU3J2lTA4CnMyGBbryRHvQW25wZkupke+THqOVjeG YGjZMYfVDgCW14Mcgz2l1lqGxtld+M5oKZ/2NGxADVsO7g8OQZtG8TrqF36ngRLNV6io sIZg== X-Received: by 10.58.97.165 with SMTP id eb5mr8474157veb.40.1359751192498; Fri, 01 Feb 2013 12:39:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.58.46.80 with HTTP; Fri, 1 Feb 2013 12:39:32 -0800 (PST) In-Reply-To: References: From: Lukasz Stafiniak Date: Fri, 1 Feb 2013 21:39:32 +0100 Message-ID: To: Ashish Agarwal Cc: Caml List Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] deep coercion does not work for some stdlib types On Fri, Feb 1, 2013 at 9:27 PM, Ashish Agarwal wrote: > > But for arrays it doesn't work: > > # let a = Array.of_list l;; > val a : N.t array = [|1; 2; 3|] > > # (a :> int array);; > Error: Type N.t array is not a subtype of int array > > Is this because the array type does not have a variance annotation? If so, > why doesn't it? You must have heard about the "mistake" of Go having covariant arrays. In OCaml, arrays are invariant because they are mutable. After you have coerced "let b = (a :> X.t array)", you can modify "a.(0) <- y" with a value "y" that is not "X.t". It would be great to have a separate type "tuple", supported by Pervasives, that differs from "array" only in that it is immutable and covariant.