From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA02296; Sat, 6 Dec 2003 00:23:39 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA02730 for ; Sat, 6 Dec 2003 00:23:38 +0100 (MET) Received: from bob.west.spy.net (mail.west.spy.net [66.149.231.226]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hB5NNbr10454 for ; Sat, 6 Dec 2003 00:23:37 +0100 (MET) Received: from [10.9.254.240] (sjc-dist3-e3.2wire.com [63.203.253.2]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client did not present a certificate) by bob.west.spy.net (Postfix) with ESMTP id 66FAB59F6 for ; Fri, 5 Dec 2003 15:23:29 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v606) Content-Transfer-Encoding: 7bit Message-Id: <05C74CE4-277A-11D8-8B9B-000393CFE6B8@spy.net> Content-Type: text/plain; charset=US-ASCII; format=flowed To: Caml Mailing List From: Dustin Sallings Subject: [Caml-list] type error in Set Date: Fri, 5 Dec 2003 15:23:24 -0800 X-Mailer: Apple Mail (2.606) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; clue:01 stringset:01 stringset:01 argv:01 endline:01 endline:01 val:01 rec:01 eof:02 eof:02 compile:02 module:03 string:03 string:03 sys:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I have an error I don't quite understand. Can someone give me a clue? I get an error in the following code: module StringSet = Set.Make(String);; let main() = let allFields = Fileutils.fold_file_lines (fun l m -> StringSet.add l m) StringSet.empty Sys.argv[1] in print_endline("All fields --"); StringSet.iter print_endline allFields; print_endline("/All fields --"); ;; It fails to compile on the due to the the following error (where 18/30-31 is the m in ``(fun l m -> StringSet.add l m)'' File "spreadsheetPivot.ml", line 18, characters 30-31: This expression has type 'a -> 'b but is here used with type StringSet.t = Set.Make(String).t The documentation for fold_file_lines looks like this: ``val fold_file_lines : (string -> 'a -> 'a) -> 'a -> string -> 'a'' and I know ``StringSet.add "hello" StringSet.empty'' works. fold_file_lines is defined as let fold_file_lines f init_value fn = operate_on_file (fold_lines f init_value) fn ;; where operate_on_file is let operate_on_file f fn = let ch = open_in fn in try let rv = f ch in close_in ch; rv with x -> close_in ch; raise x ;; and fold_lines is let rec fold_lines f init_value ch = let line,eof = try (input_line ch), false with End_of_file -> "", true in if eof then init_value else fold_lines f (f line init_value) ch ;; -- Dustin Sallings ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners