On Tue, 27 Sep 2011, Christophe Papazian wrote:
uhm, I have a couple of questions I don't understand on your
explanation:
- why the most general type is int->'a and not 'a -> 'b?
Because if I need a function of type int -> 'a I can give a function of type
'a -> 'b.
But if I need a function of type 'a -> 'b I can not use a function of type
int -> 'a.
So int -> 'a is more general and 'a -> 'b is more specific.
General rule : if a < b then (a->c) > (b->c)
probably this is a question whose answer will be RTFM but I'll try to
get your mercy (;-)): what define that a is lesser than b? is there a
table of the precendece among types?
- does this mean that I can't have a general type that could be matched
by 'a -> 'a list -> 'a list and int -> int -> int ?
if you want to get a supertype of a -> b and c -> d you need to
find a subtype of a and c AND find a supertype of b and d.
So for example for ('a -> ( 'a list -> 'a list)) and (int -> (int -> int))
you need
- a subtype of 'a and int : it's int. you have one.
- a supertype of ('a list -> 'a list) and (int -> int) (reapply the same
procedure)
-a subtype of 'a list and int : there is no such thing in ocaml, so
there is no supertype.
ok I see
So to answer your question, you can't. But as Jacques Garrigue said, you
don't need either, and you can use abstract type and "with type"
construction.
uhm, as I replied to Jacques I tried but the error persists probably I
don't know enough OCaML to do that.
thanks a lot
Walter
--
--
Caml-list mailing list. Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs