Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Questions about types and objects
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Cole <rcole@i...>
Subject: [Caml-list] Questions about types and objects
Hello all, I'm new to ocaml and getting the following type error and I 
don't understand why:

File "concept_lattice_editor.ml", line 99, characters 28-35:
This expression has type
  ('a, 'b) Concept_lattice.concept_lattice =
    < determine_contingent : int -> unit;
      down_closure : int Rb_set.tree -> int Rb_set.tree;
      downset : int -> int Rb_set.tree;
      has_all_lower_covers_in : int Rb_set.tree -> int -> bool;
      has_all_upper_covers_in : int Rb_set.tree -> int -> bool;
      has_lower_covers_in : int Rb_set.tree -> int -> bool;
      has_upper_covers_in : int Rb_set.tree -> int -> bool;
      index : ('a, 'b) Concept.concept -> int; insert_top : int -> unit;
      insertion_site_from_bottom : int -> int Rb_set.tree;
      iter : (int -> unit) -> unit;
      iter_downset : (int -> unit) -> int -> unit;
      iter_upset : (int -> unit) -> int -> unit;
      lower_cover_union : int Rb_set.tree -> int Rb_set.tree;
      lower_covers : int -> int Rb_set.tree;
      next_cochain_down : int Rb_set.tree ->
                          int Rb_set.tree -> int Rb_set.tree;
      next_cochain_up : int Rb_set.tree -> int Rb_set.tree -> int 
Rb_set.tree;
      trace : out_channel -> unit;
      trace_tree : out_channel -> int Rb_set.tree -> string -> unit;
      upper_cover_union : int Rb_set.tree -> int Rb_set.tree;
      upper_covers : int -> int Rb_set.tree; upset : int -> int Rb_set.tree;
      word : int -> ('a, 'b) Concept.concept >
but is here used with type
  Hasse_diagram.abstract_hasse_diagram =
    < iter : (int -> unit) -> unit; upper_covers : int -> int Rb_set.tree;
      upset : int -> int Rb_set.tree >
Only the first object type has a method determine_contingent
make: *** [concept_lattice_editor.cmx] Error 2

 From an expression:

      diagram#make_from_hasse lattice;

Now "('a,'b) concept_lattice" inherits from "('a,'b) concept 
hasse_diagram" which in turn inherits from "abstract_hasse_diagram".

So my question is: why isn't my ('a,'b) concept_lattice a refinement of 
abstract_hasse_diagram and thus able to be passed to 
diagram#make_from_hasse.

Here's the make_from_hasse method on diagram:

  method make_from_hasse : abstract_hasse_diagram -> unit 
    = fun hd ->
      let set_vect x =
	if (count (hd#upper_covers x)) == 1 then
	  vect#insert_mapping x self#next_vector
	else ()
    in
    let set_rep x =
      let set_rep_cand cand =
	if vect#is_domain_member cand then
	  rep#insert x cand
	else ()
      in
	iter set_rep_cand (hd#upset x);
	set_rep_cand x;
    in
      hd#iter set_vect;
      hd#iter set_rep;
      ()


regards,

Richard.

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