This is what I have so far. Isn\'t this all that you need? I keep getting the error \"Error: Unbound module Std\"
let r file =
let chan = open_in file in
An imperative solution using just the standard library:
let read_file filename =
let lines = ref [] in
let chan = open_in filename in
try
while true; do
lines := input_line chan :: !lines
done; !lines
with End_of_file ->
close_in chan;
List.rev !lines ;;
If you have the Batteries-included library you could read a file into an Enum.t and iterate over it as follows:
let filelines = File.lines_of filename in
Enum.iter ( fun line -> (*Do something with line here*) ) filelines