From: "Sylvain BOULM'E" <Sylvain.Boulme@lip6.fr>
To: "Mattias Waldau" <mattias.waldau@abc.se>
Cc: caml-list@inria.fr
Subject: Re: Why can't I use val mover : < move : int -> unit; .. > list -> unit ?
Date: Thu, 11 Jan 2001 10:29:55 +0100 [thread overview]
Message-ID: <200101110929.KAA02719@baltazard.lip6.fr> (raw)
In-Reply-To: Your message of "Wed, 10 Jan 2001 13:39:47 +0100." <HDEEKOMJILGEIHIMAPCDCEFFDNAA.mattias.waldau@abc.se>
Hi,
Lists are polymorphic but they are uniform : elements of a list must have all
the same type (which can be any type).
Hence, "mover" is a function that expects a list of objects, all of the same
type, and which type contains a method "move".
Thus, with
q: p1d_1
p: p1d_2
Expression "[q;q]" is of type "p1d_1 list" and "[p;p]" is of type "p1d_2 list",
thus "mover [q;q]" and "mover [p;p]" are well-typed.
But "[p;q]" is not well-typed.
Here, p1d_2 is subtype of p1d_1 : you can coerce p to have the type p1d_1.
Thus "[(p:>p1d_1);q]" is of type p1d_1 list.
And "mover [(p:>p1d_1);q]" is well-typed.
Sylvain.
prev parent reply other threads:[~2001-01-11 9:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-10 12:39 Mattias Waldau
2001-01-10 19:16 ` Brian Rogoff
2001-01-11 9:07 ` Mattias Waldau
2001-01-11 12:26 ` Michel Schinz
2001-01-11 13:09 ` Sylvain BOULM'E
2001-01-10 19:58 ` Alain Frisch
2001-01-11 9:29 ` Sylvain BOULM'E [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=200101110929.KAA02719@baltazard.lip6.fr \
--to=sylvain.boulme@lip6.fr \
--cc=caml-list@inria.fr \
--cc=mattias.waldau@abc.se \
/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