I am currently working through "Real Word OCaml" and one of the main examples with named / tagged parameters does not work (using utop 4.01.0):
let languages = ["OCaml"; "Perl"; "C"];; List.map ~f:String.length languages;;
It produces:
Error: The function applied to this argument has type 'a list -> 'b list This argument cannot be applied with label ~f
While:
List.map String.length languages;;
It produces the expected output [5; 4; 1] [5; 4; 1] [5; 4; 1] .
caml.inria.fr mentions that:
In the main language, as in most languages, the arguments are anonymous.
Does this mean that I have to include some kind of external library for this code to work?
EDIT Here is my ~/.ocamlinit (in accordance with the installation instructions for the book ):
(* Added by OPAM. *) let () = try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH") with Not_found -> () ;; #use "topfind" #camlp4o #thread #require "core.top" #require "core.syntax"
named-parameters ocaml utop
Frank schmitt
source share