caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Pxp objects inside class definition
@ 2002-07-09  8:35 Gaurav Chanda
  2002-07-09 12:20 ` Gerd Stolpmann
  0 siblings, 1 reply; 2+ messages in thread
From: Gaurav Chanda @ 2002-07-09  8:35 UTC (permalink / raw)
  To: caml-list

Hello

I am using the Polymorphic XML Parser (PXP) to parse XML documents. I have made 2 files : point.ml and point.mli, which contain simple class definitions.

The file point.mli contains:

open Pxp_yacc ;
open Pxp_document ;
open Pxp_types ;

class type point_sig =
        object
                value mutable x : Pxp_document.node 'a;
        end;

class point : point_sig ;


The file point.ml contains:

open Pxp_yacc ;
open Pxp_document ;
open Pxp_types ;

class type point_sig =
        object
                value mutable x : Pxp_document.node 'a;
        end ;

value def = "<def></def>" ;
value def = parse_wfdocument_entity default_config (from_string def) default_spec ;
value defr = def#root ;

class point:point_sig =
        object
                value mutable x = defr;
        end;

I get an error message while compilation. My compilation command is : 
ocamlopt -pp "camlp4r pa_extend.cmo" -I +camlp4 -I Ty/ -I /usr/lib/ocaml/site-lib/netstring -I /usr/lib/ocaml/site-lib/pxp-engine  -I /usr/lib/ocaml/site-lib/pxp-lex-iso88591/ -c point.mli point.ml


The error message is : 

File "point.ml", line 15, characters 8-67:
The class type
  object
    val mutable x :
      ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
  end
is not matched by the class type point_sig
The class type
  object
    val mutable x :
      ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
  end
is not matched by the class type
  object
    val mutable x :
      ('a Pxp_document.node #Pxp_document.extension as 'a) Pxp_document.node
  end
The instance variable x has type
  (('a Pxp_document.node as 'b) Pxp_document.extension as 'a)
  Pxp_document.node =
    < add_node : ?force:bool -> 'b -> unit;
      add_pinstr : Pxp_dtd.proc_instruction -> unit;
      append_node : 'b -> unit; attribute : string -> Pxp_types.att_value;
      attribute_names : string list;
      attribute_type : string -> Pxp_types.att_type;
      attributes : (string * Pxp_types.att_value) list;
      attributes_as_nodes : 'b list;
      classify_data_node : 'b -> Pxp_document.data_node_classification;
      comment : string option; complement_attlist : unit -> unit;
      create_data : Pxp_dtd.dtd -> string -> 'b;
      create_element : ?name_pool_for_attribute_values:Pxp_types.pool ->
                       ?position:string * int * int ->
                       ?valcheck:bool ->
                       ?att_values:(string * Pxp_types.att_value) list ->
                       Pxp_dtd.dtd ->
                       Pxp_document.node_type -> (string * string) list -> 'b;
      create_other : ?position:string * int * int ->
                     Pxp_dtd.dtd -> Pxp_document.node_type -> 'b;
      data : string; delete : unit; dtd : Pxp_dtd.dtd;
      dump : Format.formatter -> unit; encoding : Pxp_types.rep_encoding;
      extension : 'a; id_attribute_name : string;
      id_attribute_value : string; idref_attribute_names : string list;
      insert_nodes : ?pos:int -> 'b list -> unit;
      internal_adopt : 'b option -> int -> unit;
      internal_delete : 'b -> unit;
      internal_init : string * int * int ->
                      Pxp_types.pool option ->
                      bool ->
                      Pxp_dtd.dtd ->
                      string ->
                      (string * string) list ->
                      (string * Pxp_types.att_value) list -> unit;
      internal_init_other : string * int * int ->
                            Pxp_dtd.dtd -> Pxp_document.node_type -> unit;
      internal_set_pos : int -> unit; iter_nodes : ('b -> unit) -> unit;
      iter_nodes_sibl : ('b option -> 'b -> 'b option -> unit) -> unit;
      local_validate : ?use_dfa:bool ->
                       ?check_data_nodes:bool -> unit -> unit;
      localname : string; namespace_info : 'a Pxp_document.namespace_info;
      namespace_manager : Pxp_dtd.namespace_manager; namespace_uri :
      string; next_node : 'b; node_path : int list; node_position : int;
      node_type : Pxp_document.node_type; normprefix : string;
      nth_node : int -> 'b; optional_list_attribute : string -> string list;
      optional_string_attribute : string -> string option;
      orphaned_clone : 'b; orphaned_flat_clone : 'b; parent : 'b;
 pinstr : string -> Pxp_dtd.proc_instruction list;
      pinstr_names : string list; position : string * int * int;
      previous_node : 'b;
      quick_set_attributes : (string * Pxp_types.att_value) list -> unit;
      remove : unit -> unit;
      remove_nodes : ?pos:int -> ?len:int -> unit -> unit;
      required_list_attribute : string -> string list;
      required_string_attribute : string -> string;
      reset_attribute : string -> unit; root : 'b;
      set_attribute : ?force:bool -> string -> Pxp_types.att_value -> unit;
      set_attributes : (string * Pxp_types.att_value) list -> unit;
      set_comment : string option -> unit; set_data : string -> unit;
      set_namespace_info : 'a Pxp_document.namespace_info option -> unit;
      set_nodes : 'b list -> unit; sub_nodes : 'b list;
      validate : unit -> unit; validate_attlist : unit -> unit;
      validate_contents : ?use_dfa:bool ->
                          ?check_data_nodes:bool -> unit -> unit;
      write : ?prefixes:string list ->
              ?default:string ->
              Pxp_types.output_stream -> Pxp_types.encoding -> unit >
but is expected to have type
  ('c Pxp_document.node #Pxp_document.extension as 'c) Pxp_document.node =
    < add_node : ?force:bool -> 'c Pxp_document.node -> unit;
      add_pinstr : Pxp_dtd.proc_instruction -> unit;
      append_node : 'c Pxp_document.node -> unit;
      attribute : string -> Pxp_types.att_value;
      attribute_names : string list;
      attribute_type : string -> Pxp_types.att_type;
      attributes : (string * Pxp_types.att_value) list;
      attributes_as_nodes : 'c Pxp_document.node list;
      classify_data_node : 'c Pxp_document.node ->
                           Pxp_document.data_node_classification;
      comment : string option; complement_attlist : unit -> unit;
      create_data : Pxp_dtd.dtd -> string -> 'c Pxp_document.node;
      create_element : ?name_pool_for_attribute_values:Pxp_types.pool ->
                       ?position:string * int * int ->
                       ?valcheck:bool ->
                       ?att_values:(string * Pxp_types.att_value) list ->
                       Pxp_dtd.dtd ->
                       Pxp_document.node_type ->
                       (string * string) list -> 'c Pxp_document.node;
      create_other : ?position:string * int * int ->
                     Pxp_dtd.dtd ->
                     Pxp_document.node_type -> 'c Pxp_document.node;
      data : string; delete : unit; dtd : Pxp_dtd.dtd;
      dump : Format.formatter -> unit; encoding : Pxp_types.rep_encoding;
      extension : 'c; id_attribute_name : string;
      id_attribute_value : string; idref_attribute_names : string list;
      insert_nodes : ?pos:int -> 'c Pxp_document.node list -> unit;
      internal_adopt : 'c Pxp_document.node option -> int -> unit;
      internal_delete : 'c Pxp_document.node -> unit;
      internal_init : string * int * int ->
                      Pxp_types.pool option ->
                      bool ->
                      Pxp_dtd.dtd ->
                      string ->
                      (string * string) list ->
                      (string * Pxp_types.att_value) list -> unit;
      internal_init_other : string * int * int ->
                            Pxp_dtd.dtd -> Pxp_document.node_type -> unit;
      internal_set_pos : int -> unit;
      iter_nodes : ('c Pxp_document.node -> unit) -> unit;
      iter_nodes_sibl : ('c Pxp_document.node option ->
                         'c Pxp_document.node ->
                         'c Pxp_document.node option -> unit) ->
 unit;
      local_validate : ?use_dfa:bool ->
                       ?check_data_nodes:bool -> unit -> unit;
      localname : string; namespace_info : 'c Pxp_document.namespace_info;
      namespace_manager : Pxp_dtd.namespace_manager; namespace_uri :
      string; next_node : 'c Pxp_document.node; node_path : int list;
      node_position : int; node_type : Pxp_document.node_type;
      normprefix : string; nth_node : int -> 'c Pxp_document.node;
      optional_list_attribute : string -> string list;
      optional_string_attribute : string -> string option;
      orphaned_clone : 'c Pxp_document.node;
      orphaned_flat_clone : 'c Pxp_document.node;
      parent : 'c Pxp_document.node;
      pinstr : string -> Pxp_dtd.proc_instruction list;
      pinstr_names : string list; position : string * int * int;
      previous_node : 'c Pxp_document.node;
      quick_set_attributes : (string * Pxp_types.att_value) list -> unit;
      remove : unit -> unit;
      remove_nodes : ?pos:int -> ?len:int -> unit -> unit;
      required_list_attribute : string -> string list;
      required_string_attribute : string -> string;
      reset_attribute : string -> unit; root : 'c Pxp_document.node;
      set_attribute : ?force:bool -> string -> Pxp_types.att_value -> unit;
      set_attributes : (string * Pxp_types.att_value) list -> unit;
      set_comment : string option -> unit; set_data : string -> unit;
      set_namespace_info : 'c Pxp_document.namespace_info option -> unit;
      set_nodes : 'c Pxp_document.node list -> unit;
      sub_nodes : 'c Pxp_document.node list; validate : unit -> unit;
      validate_attlist : unit -> unit;
      validate_contents : ?use_dfa:bool ->
                          ?check_data_nodes:bool -> unit -> unit;
      write : ?prefixes:string list ->
              ?default:string ->
              Pxp_types.output_stream -> Pxp_types.encoding -> unit >
Type 'a = 'a Pxp_document.node Pxp_document.extension
is not compatible with type
  'c =
    < clone : 'c; node : 'c Pxp_document.node;
      set_node : 'c Pxp_document.node -> unit; .. >
make: *** [code] Error 2



I am not being able to define PXP objects inside classes. Could you help me solve this problem ?

Thanks

Gaurav


_____________________________________________________
Supercharge your e-mail with a 25MB Inbox, POP3 Access, No Ads
and NoTaglines --> LYCOS MAIL PLUS.
http://www.mail.lycos.com/brandPage.shtml?pageId=plus 
-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Pxp objects inside class definition
  2002-07-09  8:35 [Caml-list] Pxp objects inside class definition Gaurav Chanda
@ 2002-07-09 12:20 ` Gerd Stolpmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Stolpmann @ 2002-07-09 12:20 UTC (permalink / raw)
  To: gaurav_chanda; +Cc: caml-list

Gaurav Chanda wrote:
> Hello
> 
> I am using the Polymorphic XML Parser (PXP) to parse XML documents. I have made 2 files : point.ml and point.mli, which contain simple class definitions.
> 
> The file point.mli contains:
> 
> open Pxp_yacc ;
> open Pxp_document ;
> open Pxp_types ;
> 
> class type point_sig =
>         object
>                 value mutable x : Pxp_document.node 'a;
>         end;
> 
> class point : point_sig ;
> 
> 
> The file point.ml contains:
> 
> open Pxp_yacc ;
> open Pxp_document ;
> open Pxp_types ;
> 
> class type point_sig =
>         object
>                 value mutable x : Pxp_document.node 'a;
>         end ;
> 
> value def = "<def></def>" ;
> value def = parse_wfdocument_entity default_config (from_string def) default_spec ;
> value defr = def#root ;
> 
> class point:point_sig =
>         object
>                 value mutable x = defr;
>         end;
> 
> I get an error message while compilation. My compilation command is : 
> ocamlopt -pp "camlp4r pa_extend.cmo" -I +camlp4 -I Ty/ -I /usr/lib/ocaml/site-lib/netstring -I /usr/lib/ocaml/site-lib/pxp-engine  -I /usr/lib/ocaml/site-lib/pxp-lex-iso88591/ -c point.mli point.ml
> 
> 
> The error message is : 
> 
> File "point.ml", line 15, characters 8-67:
> The class type
>   object
>     val mutable x :
>       ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
>   end
> is not matched by the class type point_sig
> The class type
>   object
>     val mutable x :
>       ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
>   end
> is not matched by the class type
>   object
>     val mutable x :
>       ('a Pxp_document.node #Pxp_document.extension as 'a) Pxp_document.node
>   end
[...]
> 
> I am not being able to define PXP objects inside classes. Could you help me solve this problem ?

Hi Garuav,

(the following in classic syntax)

the problem is that  'a Pxp_document.node  is not the full type, because 
there is a constraint on the parameter of the class Pxp_document.node,
and the compiler correctly augments the type such that it reads
('a Pxp_document.node #Pxp_document.extension as 'a) Pxp_document.node.
However, defr has the type
('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node,
which is not the same. This is all the long error message wants to tell
you.

The solution is quite simple: Use the complete type instead of
'a Pxp_document.node, i.e.

class type point_sig =
object
   val mutable x :
    ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
end

Sorry that the types of PXP are that complicated.
('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
reflects the fact that nodes have extensions, and the extensions are
recursively bound to their nodes. This is sometimes a bit unhandy.

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
------------------------------------------------------------

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-09 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-09  8:35 [Caml-list] Pxp objects inside class definition Gaurav Chanda
2002-07-09 12:20 ` Gerd Stolpmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).