Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] 'b is unbound
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Damien <Damien.Pous@e...>
Subject: Re: [Caml-list] 'b is unbound
On Tue, 11 May 2004 23:31:48 -0700 briand@aracnet.com wrote:
 
> I'm getting the following error:
> 
>       method op :
>         (float, 'a, 'b) Bigarray.Array2.t ->
>         float array -> float array -> unit
>     end
> The method op has type
>   (float, 'a, 'b) Bigarray.Array2.t -> float array -> float array ->
>   unit
> where 'b is unbound
> 
> Is 'b really unbound, or is the inferencer simply unable to figure out
> what the type should be ?

polymorphic methods require to be explicitly typed
(this kind of type inference should lead to the one for system F)

# class o = object method id x = x end;;
Some type variables are unbound in this type:
  class o : object method id : 'a -> 'a end
The method id has type 'a -> 'a where 'a is unbound

# class o = object method id: 'a.'a -> 'a = fun x -> x end;;
class o : object method id : 'a -> 'a end
# let o = new o in o#id 5, o#id "toto";;
- : int * string = (5, "toto")


or maybe you want the whole class to be parametrized wrt 'a :

# class ['a] o = object method id (x:'a) = x end;;
class ['a] o : object method id : 'a -> 'a end
# let o = new o in o#id 5, o#id "toto";;
This expression has type string but is here used with type int

hope this helps,
damien

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