From: Ingo Bormuth <ibormuth@efil.de>
To: caml-list@inria.fr
Cc: ingo@bormuth.org
Subject: Reference to polymorphic function ?
Date: Tue, 13 Sep 2005 14:38:43 +0200 [thread overview]
Message-ID: <20050913123843.GA9640@kruemel> (raw)
Hi list,
the following declaration of put_to_screen nicely accepts all kinds
of values as v. This is the expected behaviour.
# let put_to_screen v = print_string ( Marshal.to_string v [] ) ;;
val put_to_screen : 'a -> unit = <fun>
# put_to_screen "test" ;;
%%%%%test- : unit = ()
# put_to_screen 5 ;;
%%%%%E- : unit = ()
Nevertheless, if I store the polymorphic function in a reference to
create a closure for all kinds of output methodeis, any attemps to use
that function are thwarted by the type interferer.
# let put = ref put_to_screen ;;
val put : ('_a -> unit) ref = {contents = <fun>}
# !put "test" ;;
%%%%%%test- : unit = ()
# !put 5 ;;
This expression has type int but is here used with type string
How can I keep the interferer from explicitly resolving the type of v ?
# put;;
- : (string -> unit) ref = {contents = <fun>}
Thanks !
--
+--------------------------------------------------------+
| Ingo Bormuth, voicebox & telefax: +49-12125-10226517 |
| GnuPG key 86326EC9 at http://ibormuth.efil.de/contact |
+--------------------------------------------------------+
next reply other threads:[~2005-09-13 12:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-13 12:38 Ingo Bormuth [this message]
2005-09-14 21:08 ` [Caml-list] " Stéphane Glondu
2005-09-14 23:48 ` Jacques Garrigue
2005-09-15 6:31 ` Olivier Andrieu
2005-09-15 7:00 ` Jacques Garrigue
2005-09-15 10:31 ` [SOLVED] " Ingo Bormuth
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=20050913123843.GA9640@kruemel \
--to=ibormuth@efil.de \
--cc=caml-list@inria.fr \
--cc=ingo@bormuth.org \
/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