caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Andrieu <andrieu@ijm.jussieu.fr>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: ibormuth@efil.de, caml-list@inria.fr
Subject: Re: [Caml-list] Reference to polymorphic function ?
Date: Thu, 15 Sep 2005 08:31:30 +0200	[thread overview]
Message-ID: <17193.5442.928760.693881@karryall.dnsalias.org> (raw)
In-Reply-To: <20050915.084814.127622622.garrigue@math.nagoya-u.ac.jp>

 Jacques Garrigue [Thursday 15 September 2005] :
 >
 > From: Ingo Bormuth <ibormuth@efil.de>
 > 
 > > 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 ?
 > 
 > You cannot: this would be unsound.
 > Actually, this is the opposite: you want to tell in advance the
 > inferer that put is polymorphic, and that only polymorphic values
 > should be accepeted. The simplest way to do this is to define a new
 > type:
 > 
 > type put = {put: 'a -> unit} ;;
 > let put = {put = put_to_screen} ;;
 > put.put "test";;
 > put.put 5;;

did you mean :

 type put = {put: 'a. 'a -> unit} ;;

or is the explicit polymorphic parameter not required anymore (like
polymorphic methods in class types) ?

-- 
   Olivier


  reply	other threads:[~2005-09-15  6:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-13 12:38 Ingo Bormuth
2005-09-14 21:08 ` [Caml-list] " Stéphane Glondu
2005-09-14 23:48 ` Jacques Garrigue
2005-09-15  6:31   ` Olivier Andrieu [this message]
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=17193.5442.928760.693881@karryall.dnsalias.org \
    --to=andrieu@ijm.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    --cc=ibormuth@efil.de \
    /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;
as well as URLs for NNTP newsgroup(s).