caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: oleg@okmij.org
To: martindemello@gmail.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] "subclassing" a char map
Date: 17 Sep 2013 08:13:27 -0000	[thread overview]
Message-ID: <20130917081327.69327.qmail@www1.g3.pair.com> (raw)
In-Reply-To: <CAFrFfuGg3n4m5AU1QtE6GahMgdfADfP6ohbrxd5zpM8ju-g97w@mail.gmail.com>


> I just wanted a type of char map I couldn't insert anything else other
> than A-Z into, that the typechecker would prevent me from mixing with
> the regular char map.

Using the abstract type and restricting its constructors -- that is,
controlling the ways the values of that type can be created -- lets us
statically ensure quite strong invariants. For example, subranging (as
in your A-Z example) or primality of integers, etc. The best part:
this type safety can be achieved without any dependent or other fancy
types, using any type system that supports abstract types.

That deep insight is from the 70s, and explained with great clarity in the
paper
        Protection in Programming Languages
        James H. Morris Jr.
        http://www.erights.org/history/morris73.pdf

His running example was also interval type. Incidentally, James
H. Morris has discovered quite a few other things we now take for
granted, for example, lazy evaluation
        http://www.cs.cmu.edu/~jhm/short%20biography.htm

The same insight -- the use of an abstract data type whose values can only
be produced by a trusted kernel, and the use of a type system to guarantee this
last property -- underlies Robin Milner's Edinburgh LCF theorem prover,
written at about the same time in early 1970s. ML was designed as a
scripting language of that prover.



      parent reply	other threads:[~2013-09-17  8:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-15 22:29 Martin DeMello
2013-09-16  4:20 ` Ivan Gotovchits
2013-09-16  4:31   ` Martin DeMello
2013-09-16  7:42     ` Goswin von Brederlow
2013-09-16 21:09       ` Martin DeMello
2013-09-17  8:13     ` oleg [this message]

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=20130917081327.69327.qmail@www1.g3.pair.com \
    --to=oleg@okmij.org \
    --cc=caml-list@inria.fr \
    --cc=martindemello@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;
as well as URLs for NNTP newsgroup(s).