From: Andrew Bagdanov <andrew@science.uva.nl>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Specifying abstract type in a record
Date: Fri, 12 Nov 2004 17:40:00 +0100	[thread overview]
Message-ID: <16788.59232.464964.613076@mojave.science.uva.nl> (raw)
In-Reply-To: <4194E0C7.4060102@trdlnk.com>
josh writes:
 > OK,  Here's what I'm trying to do:
 > 
 > # type doer = { file_name:string ; actor: ('a -> unit) };;
 > 
 > But when I do this, it tells me that I've got "Unbound type parameter 'a ".
 > 
You need to add a type parameter to the doer type:
 # type 'a doer = {file_name:string; actor: ('a -> unit) };;
 type 'a doer = { file_name : string; actor : 'a -> unit; }
This binds the type parameter 'a in your original definition.  Now
things should work the way you want:
 # let b = {file_name = "one"; actor = (fun x -> () ) };;
 val b : 'a doer = {file_name = "one"; actor = <fun>}
 # b.actor 10;;
 - : unit = ()
Note that in this definition, b.actor remains polymorphic.  If you
were to do this:
 # let b = {file_name = "one"; actor = (fun x -> Printf.printf "%d\n" x) };;
 val b : int doer = {file_name = "one"; actor = <fun>}
then 'a becones concrete (int).
Hope this helps...
-Andy
next prev parent reply	other threads:[~2004-11-12 16:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-11  8:35 module type Pietro Abate
2004-11-11  8:56 ` [Caml-list] " skaller
2004-11-11  9:09   ` Pietro Abate
2004-11-11  9:48     ` Virgile Prevosto
2004-11-12 16:11       ` Specifying abstract type in a record josh
2004-11-12 16:33         ` [Caml-list] " Luc Maranget
2004-11-12 16:37         ` Aleksey Nogin
2004-11-12 16:37         ` Richard Jones
2004-11-12 16:40         ` Andrew Bagdanov [this message]
2004-11-12 16:44         ` Matt Gushee
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=16788.59232.464964.613076@mojave.science.uva.nl \
    --to=andrew@science.uva.nl \
    --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