From: Richard Jones <rich@annexia.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Yet another question about insufficient polymorphism
Date: Tue, 18 Mar 2008 10:56:44 +0000 [thread overview]
Message-ID: <20080318105643.GA26219@annexia.org> (raw)
In-Reply-To: <20080312193431.GA10622@annexia.org>
On Wed, Mar 12, 2008 at 07:34:32PM +0000, Richard Jones wrote:
> I have a signature like this:
>
> newt.mli:
>
> type 'a component
>
> val form_add_component :
> [> `Form ] component -> [> `Component ] component -> unit
> val form_add_components :
> [> `Form ] component -> [> `Component ] component list -> unit
>
> An implementation like this:
>
> newt.ml:
>
> type 'a component = {
> co : newtComponent;
> mutable in_form : bool;
> }
[...]
> 04_form.ml:
>
> let text = textbox 1 1 15 5 [WRAP; SCROLL] in
> textbox_set_text text "This is some text in a reflowed text box.";
> let b1 = button 5 8 " OK " in
> let b2 = button 5 13 "Cancel" in
> let form = form None None [] in
> form_add_components form [text; b1; b2];
> ^^
The answer to this, pointed out to me by milanst, is to write the type
like this:
type _component = {
co : newtComponent;
mutable in_form : bool;
}
type 'a component = _component
which works as expected, without any "casts" needed on the call to
form_add_components.
Rich.
--
Richard Jones
Red Hat
prev parent reply other threads:[~2008-03-18 10:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-12 19:34 Richard Jones
[not found] ` <95513600803121319y508923a1vb36ac59c21e93f5b@mail.gmail.com>
[not found] ` <20080312205911.GA14545@annexia.org>
[not found] ` <95513600803121457l17e90817y54d419784462ae85@mail.gmail.com>
2008-03-12 22:13 ` [Caml-list] " Richard Jones
2008-03-12 22:56 ` Olivier Andrieu
2008-03-18 10:56 ` Richard Jones [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=20080318105643.GA26219@annexia.org \
--to=rich@annexia.org \
--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