[Lablgtk] Type annotation (obviously) needed...

Serge Le Huitouze serge.lehuitouze at gmail.com
Tue Dec 7 07:54:14 CET 2010


Hi there,

I have a compilation error while compiling the attached program
[The command line is included at the beginning of the file.
In order to simplify compilation, I've inlined the glade-generated
code. Caution however: you still need the glade file to run the
program].

The important part of the error message (I reproduce the complete
error message at the end of this email, but it's probably not
necessary for you, experts) goes like this:
* The universal variable 'e would escape its scope

If I comment out lines containing "store#append" and "store#set"
in function "indirect_way" (lines #82 and #83), I have no problem.
Also, note that similar calls in "direct_way" pose no compilation
problem.
So my problem obviously has to do with type wizardry, and a
type annotation should do the trick.
But I've no clue as what (and where) this annotation should be!

Can someone help me?

Thanks in advance.

--Serge

Complete error message:
File "test2.ml", line 98, characters 21-41:
Error: This expression has type
         (string * GTree.view * GTree.list_store * string GTree.column) list
       but an expression was expected of type
         (string * GTree.view *
          (< append : unit -> Gtk.tree_iter; as_model : Gtk.tree_model;
             coerce : GTree.model; flags : GtkEnums.tree_model_flags list;
             foreach : (Gtk.tree_path -> Gtk.tree_iter -> bool) -> unit;
             get : 'b. row:Gtk.tree_iter -> column:'b GTree.column -> 'b;
             get_column_type : int -> Gobject.g_type;
             get_iter : Gtk.tree_path -> Gtk.tree_iter;
             get_iter_first : Gtk.tree_iter option;
             get_path : Gtk.tree_iter -> Gtk.tree_path;
             get_row_reference : Gtk.tree_path -> GTree.row_reference;
             iter_children : ?nth:int ->
                             Gtk.tree_iter option -> Gtk.tree_iter;
             iter_has_child : Gtk.tree_iter -> bool;
             iter_n_children : Gtk.tree_iter option -> int;
             iter_next : Gtk.tree_iter -> bool;
             iter_parent : Gtk.tree_iter -> Gtk.tree_iter option;
             misc : GObj.gobject_ops; n_columns : int;
             row_changed : Gtk.tree_path -> Gtk.tree_iter -> unit;
             set : row:Gtk.tree_iter ->
                   column:'c GTree.column -> string -> 'd;
             .. >
           as 'a) *
          'c GTree.column)
         list
       Type
         GTree.list_store =
           < append : unit -> Gtk.tree_iter; as_model : Gtk.tree_model;
             clear : unit -> unit; coerce : GTree.model;
             connect : GTree.tree_sortable_signals;
             flags : GtkEnums.tree_model_flags list;
             foreach : (Gtk.tree_path -> Gtk.tree_iter -> bool) -> unit;
             get : 'b. row:Gtk.tree_iter -> column:'b GTree.column -> 'b;
             get_column_type : int -> Gobject.g_type;
             get_iter : Gtk.tree_path -> Gtk.tree_iter;
             get_iter_first : Gtk.tree_iter option;
             get_path : Gtk.tree_iter -> Gtk.tree_path;
             get_row_reference : Gtk.tree_path -> GTree.row_reference;
             get_sort_column_id : (int * Gtk.Tags.sort_type) option;
             has_default_sort_func : bool; insert : int -> Gtk.tree_iter;
             insert_after : Gtk.tree_iter -> Gtk.tree_iter;
             insert_before : Gtk.tree_iter -> Gtk.tree_iter;
             iter_children : ?nth:int ->
                             Gtk.tree_iter option -> Gtk.tree_iter;
             iter_has_child : Gtk.tree_iter -> bool;
             iter_is_valid : Gtk.tree_iter -> bool;
             iter_n_children : Gtk.tree_iter option -> int;
             iter_next : Gtk.tree_iter -> bool;
             iter_parent : Gtk.tree_iter -> Gtk.tree_iter option;
             misc : GObj.gobject_ops;
             move_after : iter:Gtk.tree_iter -> pos:Gtk.tree_iter -> bool;
             move_before : iter:Gtk.tree_iter -> pos:Gtk.tree_iter -> bool;
             n_columns : int; prepend : unit -> Gtk.tree_iter;
             remove : Gtk.tree_iter -> bool;
             row_changed : Gtk.tree_path -> Gtk.tree_iter -> unit;
             set : 'e.
                     row:Gtk.tree_iter ->
                     column:'e GTree.column -> 'e -> unit;
             set_default_sort_func : (GTree.model ->
                                      Gtk.tree_iter -> Gtk.tree_iter -> int) ->
                                     unit;
             set_sort_column_id : int -> Gtk.Tags.sort_type -> unit;
             set_sort_func : int ->
                             (GTree.model ->
                              Gtk.tree_iter -> Gtk.tree_iter -> int) ->
                             unit;
             sort_column_changed : unit -> unit;
             swap : Gtk.tree_iter -> Gtk.tree_iter -> bool >
       is not compatible with type 'a
       The universal variable 'e would escape its scope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.ml
Type: text/x-ocaml
Size: 3441 bytes
Desc: not available
URL: <http://lists.ocamlcore.org/pipermail/lablgtk-list/attachments/20101207/6bed7cd5/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ui1.glade
Type: application/x-glade
Size: 2530 bytes
Desc: not available
URL: <http://lists.ocamlcore.org/pipermail/lablgtk-list/attachments/20101207/6bed7cd5/attachment-0001.bin>
-------------- next part --------------
_______________________________________________
Lablgtk mailing list
Lablgtk at yquem.inria.fr
http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk


More information about the Lablgtk-list mailing list