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 288B47F0A6 for ; Thu, 20 Aug 2015 16:09:21 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of kennethadammiller@gmail.com) identity=pra; client-ip=209.85.218.44; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="kennethadammiller@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of kennethadammiller@gmail.com designates 209.85.218.44 as permitted sender) identity=mailfrom; client-ip=209.85.218.44; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="kennethadammiller@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-oi0-f44.google.com) identity=helo; client-ip=209.85.218.44; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="postmaster@mail-oi0-f44.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BaAQAO39VVlCzaVdFdg29pBoMfrmWNQwEJhXsCgSwHTAEBAQEBARIBAQEBBwsLCR8whCMBAQEDAQECDxEEGQEbHQEDAQsGBQQHAwoqAgIiAREBBQEcBhMaCId2AQMKCA2sBoEvPjGLQIFsgnmKbQoZJw1XhQABAQEBAQEBAwEBAQEBAQEBFAEBBA6LRYUGBAeCaYFDBZUphQWHaoFKkECESIIdEiOBFxeCHRyBbyIzgkwBAQE X-IPAS-Result: A0BaAQAO39VVlCzaVdFdg29pBoMfrmWNQwEJhXsCgSwHTAEBAQEBARIBAQEBBwsLCR8whCMBAQEDAQECDxEEGQEbHQEDAQsGBQQHAwoqAgIiAREBBQEcBhMaCId2AQMKCA2sBoEvPjGLQIFsgnmKbQoZJw1XhQABAQEBAQEBAwEBAQEBAQEBFAEBBA6LRYUGBAeCaYFDBZUphQWHaoFKkECESIIdEiOBFxeCHRyBbyIzgkwBAQE X-IronPort-AV: E=Sophos;i="5.15,714,1432591200"; d="scan'208";a="174316004" Received: from mail-oi0-f44.google.com ([209.85.218.44]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 20 Aug 2015 16:09:20 +0200 Received: by oiew67 with SMTP id w67so23266190oie.2 for ; Thu, 20 Aug 2015 07:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=J3gErVjt+7eeOk797gwZF/kwoE/9m1Iix19rYTo7iqU=; b=igg73/qur6C4oEr0O8qLDhdTfhQnXWRPysHbh/SVzwkvj8MGuILJGjdIp8BcCxQerR ACIv8Yvr1sCH0cOtgeJ3EqVlaK6xiXSnvI/qKBuQ3MWDfp15vfp8vwkZO1BPTE0vPQ3H hP8NzQ2k67ksjV+TIgzYllmPHQnYKQ/seWcmoU6DbJRpflKqLmeyPjAQSk9TIC8QeuNy wwhh+98J3wv5a4viUSYLjASdA8LbQv1g1PYcfUxCzbONmX/Bsu6lbhBnIFk75dbMmGaz Sflcl6+mJDvSJETBFJ1iGGAoAazJrR/FI/Tp48Gc+H8hM7+yn0jNhmcKTmYBl3RptOeT kRfA== MIME-Version: 1.0 X-Received: by 10.202.242.196 with SMTP id q187mr2771709oih.52.1440079759044; Thu, 20 Aug 2015 07:09:19 -0700 (PDT) Received: by 10.202.191.8 with HTTP; Thu, 20 Aug 2015 07:09:18 -0700 (PDT) In-Reply-To: References: <20150818185751.GC650@topoi.pooq.com> <20150820091051.GA15458@frosties> Date: Thu, 20 Aug 2015 10:09:18 -0400 Message-ID: From: Kenneth Adam Miller To: David Allsopp Cc: Goswin von Brederlow , caml users Content-Type: multipart/alternative; boundary=94eb2c09347a7c7955051dbeb275 Subject: Re: [Caml-list] Type Encoding Format Control --94eb2c09347a7c7955051dbeb275 Content-Type: text/plain; charset=UTF-8 It expresses intuitively, "Something which is exactly a nothing", so naturally, I would categorize that as a nothing directly of course. And you've just done precisely that with your code; foo = Some None => set that field to NULL could only represent saying that field is just exactly nothing directly. So, it's just like I said-you have to deal with the instance because it comes up in practice, and pragmatically we have to represent such cases in machine code as has been discussed. But in practicality almost never would an author sensibly keep the expanded form of Some None directly, it shows up due to code combinations only to be reduced. On Thu, Aug 20, 2015 at 10:05 AM, David Allsopp wrote: > Kenneth Adam Miller wrote: > > In the case of 2), that's interesting because such a type of > > Some None is sort of antithetical to describing anything > > sensical. Not that it's not pragmatic or doesn't occur-I'm sure > > some functions get combined in ways that stuff like this crops > > up. But I think of the typing system as being badly exercised > > if something like this arises- > > One example that springs immediately to mind: NULLable field in a > database, so 'a option is a sensible type to represent it. Now consider a > function intended to generate SQL UPDATE statements for that field: > > val update_record : ?foo:int option -> ?bar:int option -> id:int -> > baz:string -> bool > > where omitting ~foo or ~bar means "don't change foo/bar in the UPDATE > statement". Within the code for update_record: > > foo = None => don't update that field > foo = Some None => set that field to NULL > foo = Some (Some i) => set that field's value to i > > and all three cases will need different code. > > See also https://github.com/ocaml/ocaml/blob/trunk/typing/env.ml#L391 > > What's (to you) badly exercised or nonsensical in either of those > representations? > > > David > --94eb2c09347a7c7955051dbeb275 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
It expresses intuitively, "Something which is exactly= a nothing", so naturally, I would categorize that as a nothing direct= ly of course. And you've just done precisely that with your code; foo = =3D Some None =3D> set that field to NULL could only represent saying th= at field is just exactly nothing directly. So, it's just like I said-yo= u have to deal with the instance because it comes up in practice, and pragm= atically we have to represent such cases in machine code as has been discus= sed. But in practicality almost never would an author sensibly keep the exp= anded form of Some None directly, it shows up due to code combinations only= to be reduced.=C2=A0

On Thu, Aug 20, 2015 at 10:05 AM, David Allsopp <dra-news@m= etastack.com> wrote:
Kenneth Adam Miller wrote:
> In the case of 2), that's interesting because such a type of
> Some None is sort of antithetical to describing anything
> sensical. Not that it's not pragmatic or doesn't occur-I'm= sure
> some functions get combined in ways that stuff like this crops
> up. But I think of the typing system as being badly exercised
> if something like this arises-

One example that springs immediately to mind: NULLable field in a da= tabase, so 'a option is a sensible type to represent it. Now consider a= function intended to generate SQL UPDATE statements for that field:

val update_record : ?foo:int option -> ?bar:int option -> id:int ->= ; baz:string -> bool

where omitting ~foo or ~bar means "don't change foo/bar in the UPD= ATE statement". Within the code for update_record:

foo =3D None =3D> don't update that field
foo =3D Some None =3D> set that field to NULL
foo =3D Some (Some i) =3D> set that field's value to i

and all three cases will need different code.

See also https://github.com/ocaml/ocaml/= blob/trunk/typing/env.ml#L391

What's (to you) badly exercised or nonsensical in either of those repre= sentations?


David

--94eb2c09347a7c7955051dbeb275--