caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Kenneth Adam Miller <kennethadammiller@gmail.com>
To: David Allsopp <dra-news@metastack.com>
Cc: Goswin von Brederlow <goswin-v-b@web.de>,
	caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Type Encoding Format Control
Date: Thu, 20 Aug 2015 10:09:18 -0400	[thread overview]
Message-ID: <CAK7rcp9V+XXSJQVNKR_NtnM+Ho6oNZ3g7em+Po_YQ3o-+fdg6w@mail.gmail.com> (raw)
In-Reply-To: <E51C5B015DBD1348A1D85763337FB6D9E9DDC7CD@Remus.metastack.local>

[-- Attachment #1: Type: text/plain, Size: 1919 bytes --]

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 <dra-news@metastack.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
> 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
>

[-- Attachment #2: Type: text/html, Size: 2586 bytes --]

  reply	other threads:[~2015-08-20 14:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-18 17:06 Kenneth Adam Miller
2015-08-18 18:57 ` Hendrik Boom
2015-08-18 19:01   ` Kenneth Adam Miller
2015-08-18 19:44     ` Gabriel Scherer
2015-08-18 19:55       ` Kenneth Adam Miller
2015-08-18 19:58         ` Gabriel Scherer
2015-08-20  9:10       ` Goswin von Brederlow
2015-08-20 13:08         ` Kenneth Adam Miller
2015-08-20 14:05           ` David Allsopp
2015-08-20 14:09             ` Kenneth Adam Miller [this message]
2015-08-20 14:11               ` Kenneth Adam Miller
2015-08-25 12:09 ` [Caml-list] <DKIM> " Pierre Chambart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK7rcp9V+XXSJQVNKR_NtnM+Ho6oNZ3g7em+Po_YQ3o-+fdg6w@mail.gmail.com \
    --to=kennethadammiller@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dra-news@metastack.com \
    --cc=goswin-v-b@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).