Le 27/09/2011 20:43, Walter Cazzola a écrit :
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?
Disclaimer : I'm not at all an expert and i discovered these things with
these mails. But if I've understood, "a is lesser than b" means that
when a function expects an argument of type 'b, a value of type 'a can
be given to this function. For an example, List.length can take a value
of type int list, because int list < 'a list. If I remember, in fact, 'a
< 'b if a value of type 'a is also a value of type 'b.
--
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