Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: josh <josh@trdlnk.com>
To: caml-list@inria.fr
Subject: Specifying abstract type in a record
Date: Fri, 12 Nov 2004 10:11:51 -0600	[thread overview]
Message-ID: <4194E0C7.4060102@trdlnk.com> (raw)
In-Reply-To: <20041111104849.29e7e506@mpiat2314>

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 ".

However,  if I change the 'a to int like this:

# type doer = { file_name:string; actor: (int -> unit) };;

It works as expected, but is not polymorphic (which is what I was trying 
to do).
If I create an abstract type like:
# type t
# type doer = { file_name:string; actor (t -> unit) };;

It works until I try to use a created record:

# let b = {file_name = "one"; actor = (fun x -> () ) };;
# b.actor 10;;
The expression has type int but is used with type t

even if I try to do this

# type t = int;;

it doesn't work.  So, how _can_ I specify a record with an abstract 
field?  Or is this
the Wrong Way to Do Things?     Thank you for your help.

-jbs


  reply	other threads:[~2004-11-12 16:12 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       ` josh [this message]
2004-11-12 16:33         ` [Caml-list] Specifying abstract type in a record Luc Maranget
2004-11-12 16:37         ` Aleksey Nogin
2004-11-12 16:37         ` Richard Jones
2004-11-12 16:40         ` Andrew Bagdanov
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=4194E0C7.4060102@trdlnk.com \
    --to=josh@trdlnk.com \
    --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