From: Benedikt Rosenau <Benedikt.Rosenau@dlr.de>
To: caml-list@inria.fr
Subject: Some questions about type inference
Date: Thu, 26 Oct 2000 15:30:11 +0200 (DFT) [thread overview]
Message-ID: <200010261330.e9QDUDK45488@dv.go.dlr.de> (raw)
I have played with covariance. Namely, I tried to define a class
of objects with a method "eat" who would only eat objects defining
a method "eat" themselves.
The direct approach fails:
class virtual broken_carnivore =
object
method virtual eat: <eat: _; ..> -> unit
end
since there is an unbound type variable in the ellipsis.
However, the following works (more or less):
class virtual ['a] carnivore =
object
constraint 'a = ('a) #carnivore
method virtual eat: <eat: _; ..> -> unit
end
and I can only speculate how this binds the type variable.
Another piece de resistence for my understanding is the following:
match []::[] with a::b -> a = [] & b = []
works, while
match []::[] with a::b -> a = b
gives a type error.
Benedikt
next reply other threads:[~2000-10-26 14:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-26 13:30 Benedikt Rosenau [this message]
2000-10-26 16:46 ` John Max Skaller
2000-10-26 16:56 ` Didier Remy
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=200010261330.e9QDUDK45488@dv.go.dlr.de \
--to=benedikt.rosenau@dlr.de \
--cc=Benedikt.Rosenau@debis-sfr.de \
--cc=caml-list@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