Hey List,

I'm trying to create a "container" class[0] that can store a value of type 'a, and transform that value to another value of type 'b. I'm trying to do this by including a "map" method in the container that applies a function to the value and returns a new instance of container with the transformed value. Despite the annotations, the types aren't working out as I expected:

  class ['a] container (v:'a) = object
    method map (f:'a -> 'b) : 'b container = new container (f v)
  end;;
  (* class ['a] container : 'a -> object method map : ('a -> 'a) -> 'a container end  *)

I gather I'm either doing something wrong, or it's not possible. I suppose my question, which one is it? and if I'm doing something wrong, some guidance would be appreciated. Thanks!

-Spiros E.

[0]: Note that this is a minimal, contrived example of my actual problem. The actual problem came up while writing js_of_ocaml bindings.