On Tue, 11 Mar 2008 22:26:19 +0000
Jon Harrop <
jon@...> wrote:
> This is the value restriction. Basically, you can cancel arguments from both
> sides of a function definition except for the last argument in impure
> languages like OCaml:
>
> let f x y z = g 3 x y z
> let f x y = g 3 x y
> let f x = g 3 x
>
> but not:
>
> let f = g 3
Thanks a lot for the explanations.
> > > if you want a fully polymorphic version, you need to wrote it as :
> > > let append l =
> > > let rec rappend = function
> > > [] -> id
> > >
> > > | h::t -> rappend t <<- (cons h) in
> > >
> > > (rappend <<- List.rev) l
> You might prefer:
>
> let append =
> ...
> fun l -> (rappend <<- List.rev) l
This doesn't seems to change a lot at first glance, however yes, imho this is nicer this way, because the two 'l' are located closer.
Regards,
Fabrice
http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=626http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=627http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=619