> let f (x, y) =
x (x y);;
> val f : ('a -> 'a) * 'a -> 'a

This is really this:

(('a -> 'a) * 'a) -> 'a

"f" is a fn that takes a <i>single argument <i>that is a tuple, and the first elements of which is used in fn position in the body and as the receiver of the return value of itself and another value, hence everything being of type 'a. > let f x y = x (x y);; > val f : ('a -> 'a) -> 'a -> 'a "f" is a fn that takes <i>two arguments, <i>but is otherwise the same as above due to type inference. Personally, although I understand how F# has the potential to curry any function, and that "*" for tuples comes from the cartesian product representation of tuples, I find the -> and * notation of typing a little hard to follow in some cases, especailly seeing the toplevel doesn't supply parens for explicit grouping. "<b>*</b>" is also weird in that the syntax of usage ("<b>,</b>") is different than the syntax of decalaration, "<b>*</b>". If tuples were presented in a way that mimicked usage, the first case would be presented as: ('a -> 'a, 'a) -> 'a which seems more clear to me. (I understand the OCaml issue, but it seems like this would really only have broken interface files, which doesn't seem like too big a loss for the clarity - but there are probably other considerations as well that I'm not aware of.)

By on 10/30/2010 11:53 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper