diff options
author | Daniil Baturin <daniil@baturin.org> | 2014-09-12 19:34:50 +0700 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2014-09-12 19:34:50 +0700 |
commit | d9110cf7bc8a3dcf84207ea509340dbae868a44a (patch) | |
tree | b1fd2ba57307f5a663f8e7c1377ece33294ee373 /ocaml.html.markdown | |
parent | 55c269cc3c6a5678bbff3effc587edb7a1cd6e8a (diff) |
An overly simplified explanation of currying in OCaml tutorial.
Diffstat (limited to 'ocaml.html.markdown')
-rw-r--r-- | ocaml.html.markdown | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ocaml.html.markdown b/ocaml.html.markdown index 8638a291..fd5b9b2e 100644 --- a/ocaml.html.markdown +++ b/ocaml.html.markdown @@ -31,7 +31,7 @@ val a : int = 99 ``` For a source file you can use "ocamlc -i /path/to/file.ml" command -to print all names and signatures. +to print all names and type signatures. ``` $ cat sigtest.ml @@ -47,7 +47,13 @@ val a : int ``` Note that type signatures of functions of multiple arguments are -written in curried form. +written in curried form. A function that takes multiple arguments can be +represented as a composition of functions that take only one argument. +The "f(x,y) = x + y" function from the example above applied to +arguments 2 and 3 is equivalent to the "f0(y) = 2 + y" function applied to 3. +Hence the "int -> int -> int" signature, which can be read as +"(int -> int) -> int". + ```ocaml (*** Comments ***) |