* [Caml-list] Questions about types and objects
@ 2004-02-03 2:07 Richard Cole
2004-02-03 9:32 ` Richard Jones
0 siblings, 1 reply; 2+ messages in thread
From: Richard Cole @ 2004-02-03 2:07 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Questions about types and objects
2004-02-03 2:07 [Caml-list] Questions about types and objects Richard Cole
@ 2004-02-03 9:32 ` Richard Jones
0 siblings, 0 replies; 2+ messages in thread
From: Richard Jones @ 2004-02-03 9:32 UTC (permalink / raw)
Cc: caml-list
On Tue, Feb 03, 2004 at 12:07:31PM +1000, Richard Cole wrote:
> From an expression:
>
> diagram#make_from_hasse lattice;
You need to upcast it. I've never really understood why this is
necessary.
diagram#make_from_hasse (lattice :> abstract_hasse_diagram);
Rich.
--
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
Perl4Caml lets you use any Perl library in your type-safe Objective
CAML programs. http://www.merjis.com/developers/perl4caml/
-------------------
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:[~2004-02-03 9:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-03 2:07 [Caml-list] Questions about types and objects Richard Cole
2004-02-03 9:32 ` Richard Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox