Version française
Home     About     Download     Resources     Contact us    
Browse thread
module type...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: josh <josh@t...>
Subject: Specifying abstract type in a record
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