caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Walter Cazzola <cazzola@dico.unimi.it>
Cc: OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] still silly issues on polymorphic types
Date: Wed, 28 Sep 2011 08:58:36 +0900	[thread overview]
Message-ID: <6C6F75D3-BE10-47A6-90D9-65AEE678A9B3@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <alpine.LFD.2.00.1109272159470.2778@surtur.dico.unimi.it>

On 2011/09/28, at 5:22, Walter Cazzola wrote:

> I still have one problem: how can I assign to a the type 'a list? by
> using «type a= 'a list» I get
> 
> Error: Unbound type parameter 'a

Same thing: you need to make explicit the contents of the list.
So this can be type a = int list.
On the other hand if you are trying to refine the signature, you
can also write
 type t
 type a = t list
keeping t abstract.

But maybe I should first make clearer what instantiation and inclusion
mean, because this is often confusing.

For type schemes (types containing type variables), the more general
type can be used in more contexts, so it is actually a subtype, and you have

  'a -> 'b  <=  int -> 'b  < = int -> bool

I.e., by instantiating a variable you can go to a less general type,
which you can view as a super-type.

For abstract types in signatures, this works the other way round:

 sig type a = int end  <=  sig type a end

This is because an abstract type denotes existential abstraction, rather
than the universal quantification of type variables in type schemes.
So for signatures, instantiating a type declaration creates a subtype.

They still have in common that instantiation substitutes all occurrences
of a name simultaneously.

Hope this helps.

	Jacques

  reply	other threads:[~2011-09-27 23:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 11:46 Walter Cazzola
2011-09-27 12:57 ` Christophe Papazian
2011-09-27 13:49   ` Walter Cazzola
2011-09-27 15:26     ` Christophe Papazian
2011-09-27 18:43       ` Walter Cazzola
2011-09-27 19:25         ` Thibault Suzanne
2011-09-27 13:16 ` Jacques Garrigue
2011-09-27 13:58   ` Walter Cazzola
2011-09-27 19:45     ` Pierre Chopin
2011-09-27 20:22       ` Walter Cazzola
2011-09-27 23:58         ` Jacques Garrigue [this message]
     [not found]         ` <266E7048-C3BB-4B9E-9760-9D52993A1C86@math.nagoya-u.ac.jp>
2011-09-29 10:27           ` Walter Cazzola

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=6C6F75D3-BE10-47A6-90D9-65AEE678A9B3@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=cazzola@dico.unimi.it \
    /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).