caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dawid Toton <dawid.toton@uj.edu.pl>
To: caml-list@yquem.inria.fr
Subject: Quantifier in the type
Date: Wed, 15 Oct 2008 16:03:20 +0100	[thread overview]
Message-ID: <48F60638.6040101@uj.edu.pl> (raw)

Just an elementary question.

I put 'a in the interface:
val fu : 'a -> 'a
and int in the implementation:
let fu x = x + 1

So I have universal quantification: for any type 'a function fu can 
consume the argument. So my implementation doesn't comply with that 
universal quatification. And the message I get is following:

Values do not match: val fu : int -> int is not included in val fu : 'a 
-> 'a

So the declaration of value in mli file is called simply a 'value'. Is 
it intentional?
I thought that value and it's declaration are separate notions?

My reading of " val fu : 'a -> 'a " is:
 some partiular value vvv that belongs to set of values that satisfy  
"forall 'a : (vvv can be used with ('a -> 'a) type)"

But if I write
let (bar : 'a -> 'a ) = (fun x -> x + 1)
I create a value that belongs to set "exists 'a : (vvv can be used with 
('a -> 'a) type)"
So it's the other quantifier.

I think that the quantifier has to be part of type, since a type is set 
of values (and the quantifier plays important role when describing some 
of such sets).
So my question is: since we see the same string " 'a -> 'a " that refers 
to different types in different contexts, what are the rules? How is 
type definition in OCaml translated to a type?

Dawid


             reply	other threads:[~2008-10-15 15:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-15 15:03 Dawid Toton [this message]
2008-10-15 18:18 ` [Caml-list] " Florent Monnier
2008-10-16 15:33   ` Dawid Toton
2008-10-17  8:11     ` Tiphaine Turpin
2008-10-17 11:40       ` Dawid Toton
2008-10-16 23:06 ` Florent Monnier

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=48F60638.6040101@uj.edu.pl \
    --to=dawid.toton@uj.edu.pl \
    --cc=caml-list@yquem.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).