caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Michel.Mauny@inria.fr (Michel Mauny)
To: caml-list@margaux.inria.fr
Subject: Existential types variables (unix patch)
Date: Wed, 1 Dec 1993 11:57:11 +0100 (MET)	[thread overview]
Message-ID: <9312011057.AA16359@pauillac.inria.fr> (raw)

Hi,

A patch introducing a simple form of existential types (following
Laufer and Odesky's proposal) is now available for Caml-Light 0.6 on
ftp.inria.fr [192.93.2.54], file
~ftp/lang/caml-light/cl6existpatch.tar.Z

This extension provides a very simple form of abstract types and should
be suseful (at least) for teaching.

Since there is no machine-specific code in the patch, patched files
should compile on all Caml-Light 0.6 ports.

The archive essentially contains a README file, a diff file (to be given
as input to `patch'), and some documentation about this new feature.

To install it, follow the instructions given in the README file in the
archive. You'll have build a new Caml-Light system, expected to be
compatible with the old one.

What follows is an extract of the file exist.doc from the archive, to
give you an idea of the extension. More interesting examples can be
found in the archive.

Sincerely,

Michel Mauny and Francois Pottier
(Michel.Mauny@inria.fr, Francois.Pottier@ens.fr)

-----------------------------------------------------------------------------

1. What do we have more?
=========================

In this extension, type variables occuring free in type definitions
aren't errors any longer. They are considered as existentially
quantified. For instance, the following type definition is accepted:

   #type key = Key of 'a * ('a -> int);;

This means that it is now possible to build values such as:

   #let k1 = Key([1;2;3], list_length)
   #and k2 = Key(5, succ);;
   k1 : key = Key (<abstract>, <fun>)
   k2 : key = Key (<abstract>, <fun>)

The typechecker made sure that in a value "Key(x,f)", x is a valid
argument to f.

Also, we are able to decompose values of type key as:

   #let (Key(r1,f1)) = k1;;
   f1 : ?A -> int = <fun>
   r1 : ?A = <abstract>

The types of r and f have existential type variables (written "?a"),
and f can be applied to r:

   #f1 r1;;
   - : int = 3

Now, if we decompose k2, f and r (from k1) cannot be mixed with k2's
components:

  #let (Key(r2,f2)) = k2;;
   f2 : ?B -> int = <fun>
   r2 : ?B = <abstract>

   #f2 r1;;
   > Toplevel input:
   >f2 r1;;
   >   ^^
   > Expression of type ?A
   > cannot be used with type ?B

If we decompose k1 again, we obtain values f'1 and r'1 whose types are
incompatible with f1 and r1:

   #let (Key(r'1, f'1)) = k1;;
   f'1 : ?C -> int = <fun>
   r'1 : ?C = <abstract>

   #f'1 r1;;
   > Toplevel input:
   >f'1 r1;;
   >    ^^
   > Expression of type ?A
   > cannot be used with type ?C

-----------------------------------------------------------------------------




                 reply	other threads:[~1993-12-01 13:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=9312011057.AA16359@pauillac.inria.fr \
    --to=michel.mauny@inria.fr \
    --cc=caml-list@margaux.inria.fr \
    /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).