<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/12/6645b76fdaaac896907eba3358f17de9"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-05T23:23:39"
  subject="[Caml-list] type error in Set"
  prev="2003/12/31e143b28f1df16344904a64cd335b6a"
  next="2003/12/d1edcb5a954d38eb8e71435192f281fe"
  next-in-thread="2003/12/d1edcb5a954d38eb8e71435192f281fe"
  prev-thread="2003/12/15aed9cdaa87e3077ca1de4ee1e768ca"
  next-thread="2003/12/67c33fd6a80fd9bb5699e02c9519cbea"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] type error in Set">
<msg 
  url="2003/12/6645b76fdaaac896907eba3358f17de9"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-05T23:23:39"
  subject="[Caml-list] type error in Set">
<msg 
  url="2003/12/d1edcb5a954d38eb8e71435192f281fe"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-12-06T00:10:53"
  subject="Re: [Caml-list] type error in Set">
</msg>
</msg>
</thread>

<contents>

	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 -&gt; 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 -&gt; StringSet.add l m)''


File "spreadsheetPivot.ml", line 18, characters 30-31:
This expression has type 'a -&gt; '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 -&gt; 'a -&gt; 'a) -&gt; 'a -&gt; string -&gt; '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 -&gt;
         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 -&gt; "", 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

</contents>

</message>

