"Error: The function applied to this argument has type ..." when using named parameters
named-parameters, ocaml, utop
Solution
As mentioned in @rafix's comment, this can be fixed by putting
open Core.Std ;;
first.
Problem
I'm currently working through "Real Word OCaml", and one of the basic examples with named / labeled parameters doesn't seem to work (using utop 4.01.0): ``` let languages = ["OCaml"; "Perl"; "C"];; List.map ~f:String.length languages;; ``` Produces: ``` Error: The function applied to this argument has type 'a list -> 'b list This argument cannot be applied with label ~f ``` Whereas: ``` List.map String.length languages;; ``` Produces the expected output `[5; 4; 1]`. caml.inria.fr mentions that: In the core language, as in most languages, arguments are anonymous. Does this mean that I have to include some kind of external library to make this code work ? EDIT Here's my `~/.ocamlinit` file (as per 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" ```