From: David Allsopp <dra-news@metastack.com>
To: Kenneth Adam Miller <kennethadammiller@gmail.com>,
Goswin von Brederlow <goswin-v-b@web.de>
Cc: caml users <caml-list@inria.fr>
Subject: RE: [Caml-list] Type Encoding Format Control
Date: Thu, 20 Aug 2015 14:05:13 +0000 [thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9E9DDC7CD@Remus.metastack.local> (raw)
In-Reply-To: <CAK7rcp8NGOWj=LbNpB72RCKhW7KG2g0sHE1+1n2ZNtt_njoaUQ@mail.gmail.com>
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
next prev parent reply other threads:[~2015-08-20 14:05 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 [this message]
2015-08-20 14:09 ` Kenneth Adam Miller
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=E51C5B015DBD1348A1D85763337FB6D9E9DDC7CD@Remus.metastack.local \
--to=dra-news@metastack.com \
--cc=caml-list@inria.fr \
--cc=goswin-v-b@web.de \
--cc=kennethadammiller@gmail.com \
/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