From: Alain Frisch <frisch@clipper.ens.fr>
To: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
Cc: <caml-list@inria.fr>
Subject: Re: [Caml-list] Polymorphic methods
Date: Tue, 20 Nov 2001 10:33:28 +0100 (MET) [thread overview]
Message-ID: <Pine.GSO.4.33.0111201017360.3182-100000@clipper.ens.fr> (raw)
In-Reply-To: <20011120092918S.garrigue@kurims.kyoto-u.ac.jp>
Good news that polymorphic methods are still considered !
On Tue, 20 Nov 2001, Jacques Garrigue wrote:
> What would you need them for? One reason I was not so eager to start
> working on them is that they do not solve all problems of
> polymorphism. For instance, you cannot define a map method, even with
> polymorphic methods.
Oh, I never used OLabl and was not aware of this kind of restriction;
why is a map method impossible ? I can't find the argument
in your _Extending ML with semi-explicit higher order polymorphism_
I currently need polymorphic method for the Bedouin project.
We use polymorphic variants to statically enforce DTD constraints
on produced documents. For instance, we have:
val html_ :
?lang:string ->
?dir:[ `Ltr | `Rtl ] ->
('a,[< `Head ]) t ->
('a,[< `Body ]) t ->
('a,[> `Html]) t
Now I want to define GUI-like widgets, such as HTML forms, or INPUT
interactors. For instance, the form widget should have
a method html, with polymorphic type:
[< `P | `H1 | `H2 | `H3 | `H4 | `H5 | `H6 | `Ul | `Ol | `Dir | `Menu
| `Pre | `Dl | `Div | `Center | `Noscript | `Noframes | `Blockquote
| `Isindex | `Hr | `Table | `Fieldset | `Address | `Pcdata | `Tt
| `I | `B | `U | `S | `Strike | `Big | `Small | `Em | `Strong
| `Dfn | `Code | `Samp | `Kbd | `Var | `Cite | `Abbr | `Acronym
| `A | `Img | `Applet | `Object | `Font | `Basefont | `Br
| `Script | `Map | `Q | `Sub | `Sup | `Span | `Bdo | `Iframe
| `Input | `Select | `Textarea | `Label | `Button > `Input]
html list -> [> `Form] html
(btw, in the type to left of the arrow, isn't the " > `Input "
redundant ?)
Would such a method be accepted ?
As the html methods are normally (but not necessarily) used only
once to display widgets, it is possible to parametrize widget classes with
the type of their html method (this produces constraints on the
type parameter, such as : constraint 'a = [ < `P ... ]),
but then, as there is a hierarchy of objects (a widget belongs
to a form belongs to a dialog), the type parameters accumulate,
and the interface of the widget library becomes ugly.
> > Did OLabl raise some practical problems with polymorphic methods ?
>
> There was a problem of compilation speed. I have now a few ideas of
> how to improve it, but this may still mean that the change would only
> be provided as a patch.
Does the compilation scheme impact on the whole language, even for
programs not using polymorphic methods ?
> Another problem is that such methods cannot be inferred. As a result
> you can have strange type errors, because you used a method before
> knowing its actual type. In OLabl there was a warning every time you
> used a method whose type was unkwown, but I have been told it was not
> very Caml-like.
Well, with the class parametrization trick, it is also necessary
to give a type annotations (just 'a is ok, and let the type system
infer constraints on 'a).
Thank you !
Alain
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next prev parent reply other threads:[~2001-11-20 9:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-19 15:29 Alain Frisch
2001-11-20 0:29 ` Jacques Garrigue
2001-11-20 9:33 ` Alain Frisch [this message]
2001-11-20 20:55 ` Xavier Leroy
2002-07-14 23:16 [Caml-list] polymorphic methods nadji
2002-07-15 1:05 ` Jacques Garrigue
2002-07-15 2:08 ` Brian Smith
2002-07-15 16:24 ` nadji
2002-08-23 15:46 [Caml-list] Polymorphic methods Frederic Tronel
2002-08-23 17:32 ` Fred Smith
2002-08-23 18:21 ` Remi VANICAT
2003-03-12 23:07 [Caml-list] polymorphic methods Damien
2003-03-13 0:56 ` brogoff
2003-03-13 1:56 ` Jacques Garrigue
2003-03-13 9:04 ` Damien
2003-03-13 9:27 ` Jacques Garrigue
2003-03-13 14:49 ` Damien
2003-03-13 9:41 ` Olivier Andrieu
2015-12-18 9:18 Christoph Höger
2015-12-18 10:07 ` Leo White
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=Pine.GSO.4.33.0111201017360.3182-100000@clipper.ens.fr \
--to=frisch@clipper.ens.fr \
--cc=caml-list@inria.fr \
--cc=garrigue@kurims.kyoto-u.ac.jp \
/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