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 05ADF7FA14 for ; Tue, 8 Jul 2014 15:37:15 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=pra; client-ip=193.252.23.210; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=mailfrom; client-ip=193.252.23.210; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@msa.smtpout.orange.fr) identity=helo; client-ip=193.252.23.210; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="postmaster@msa.smtpout.orange.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah4BAF/zu1PB/BfSnGdsb2JhbABZDocbwESDFAGBKw8BAQEBAQgLCQkUKIQDAQEFIwQLAQVAARALGAICBRYLAgIJAwIBAgFFBgEMAQcBAYhCr3KZNxeBLI4WB4J3gUwBBJZchBqHD49+RA X-IPAS-Result: Ah4BAF/zu1PB/BfSnGdsb2JhbABZDocbwESDFAGBKw8BAQEBAQgLCQkUKIQDAQEFIwQLAQVAARALGAICBRYLAgIJAwIBAgFFBgEMAQcBAYhCr3KZNxeBLI4WB4J3gUwBBJZchBqHD49+RA X-IronPort-AV: E=Sophos;i="5.01,625,1400018400"; d="scan'208";a="84155062" Received: from msa01.smtpout.orange.fr (HELO msa.smtpout.orange.fr) ([193.252.23.210]) by mail2-smtp-roc.national.inria.fr with ESMTP; 08 Jul 2014 15:37:14 +0200 Received: from [192.168.1.133] ([92.151.60.153]) by mwinf5d54 with ME id PpdC1o0013JNEic03pdCEK; Tue, 08 Jul 2014 15:37:14 +0200 X-ME-Helo: [192.168.1.133] X-ME-Auth: bGV4aWZpQHdhbmFkb28uZnI= X-ME-Date: Tue, 08 Jul 2014 15:37:14 +0200 X-ME-IP: 92.151.60.153 Message-ID: <53BBF406.9060909@frisch.fr> Date: Tue, 08 Jul 2014 15:37:10 +0200 From: Alain Frisch User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Jacques Garrigue , Gerd Stolpmann CC: OCaML List Mailing References: <1404501528.4384.4.camel@e130> <1404559455.4384.32.camel@e130> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] Immutable strings On 07/08/2014 03:23 PM, Jacques Garrigue wrote: > Alain’s idea of using an extra type-only parameter (‘a is_a_type) works, > and it doesn’t really need to be a GADT. > But this is a bit strange to use an extra parameter where a phantom type > on string itself would solve the problem. I mentioned that some functions could behave differently according to the requested result type. For instance, a function val of_bool: 'a is_a_string -> bool -> 'a would return string literals when 'a = String and it would copy them when 'a = Bytes. Similarly, a function could memoize some strings it produces in order to return them later again, but only when 'a = String, not 'a = Bytes. Even for functions such as "copy" or "sub", it makes sense to avoid a copy in some cases (when both the input and the output are immutable, and for sub, when the range covers the entire input). So I don't think that "'a is_a_string" can really be only a phantom type. -- Alain