Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] what does this mean?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Eric C. Cooper <ecc@c...>
Subject: Re: [Caml-list] what does this mean?
On Tue, Apr 16, 2002 at 01:28:23PM -0400, Garry Hodgson wrote:
> 
> i'm getting en error message i don't understand in the following code
> fragment.  foo.ml is:
> 
> let regions = Hashtbl.create 64
> 
> type region = { name:string; coords:(int*int*int*int); countries:string
> list }
> 
> let addRegion name0 coords0 ccs =
> 	let r = { name=name0; coords=coords0; countries=ccs } in
> 	Hashtbl.add regions name0 r
> 
> when i comp[ile, i get:
> 
> $ ocamlc foo.ml
> File "foo.ml", line 9, characters 13-20:
> This expression has type ('a, 'b) Hashtbl.t but is here used with type
>   (string, region) Hashtbl.t
> The type constructor region would escape its scope
> 
> can someone explain what this means, and perhaps how to resolve it?
> thanks

The problem is that you create the regions hash table before defining
the region type.  Just move the type definition to the top, before
creating any data structures that might use it.

-- 
Eric C. Cooper          e c c @ c m u . e d u
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners