From 4e1aa9b6b427afb90db678f5b16171b1988e9365 Mon Sep 17 00:00:00 2001 From: DJ O'Leary Date: Tue, 2 Dec 2025 00:09:07 +0100 Subject: refactor(file): rename File_reader module to File --- 2025/ocaml/lib/infrastructure/file.ml | 4 ++++ 2025/ocaml/lib/infrastructure/file.mli | 3 +++ 2025/ocaml/lib/infrastructure/file_reader.ml | 4 ---- 2025/ocaml/lib/infrastructure/file_reader.mli | 3 --- 2025/ocaml/lib/presentation/cli.ml | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 2025/ocaml/lib/infrastructure/file.ml create mode 100644 2025/ocaml/lib/infrastructure/file.mli delete mode 100644 2025/ocaml/lib/infrastructure/file_reader.ml delete mode 100644 2025/ocaml/lib/infrastructure/file_reader.mli (limited to '2025/ocaml') diff --git a/2025/ocaml/lib/infrastructure/file.ml b/2025/ocaml/lib/infrastructure/file.ml new file mode 100644 index 0000000..3b49c01 --- /dev/null +++ b/2025/ocaml/lib/infrastructure/file.ml @@ -0,0 +1,4 @@ +let read filename = + let chan = In_channel.open_text filename in + let content = In_channel.input_all chan in + In_channel.close chan ; content diff --git a/2025/ocaml/lib/infrastructure/file.mli b/2025/ocaml/lib/infrastructure/file.mli new file mode 100644 index 0000000..17d4495 --- /dev/null +++ b/2025/ocaml/lib/infrastructure/file.mli @@ -0,0 +1,3 @@ +val read : string -> string +(** [read filename] is the contents of [filename] as a string. + The empty string is returned if [filename] does not exist. *) diff --git a/2025/ocaml/lib/infrastructure/file_reader.ml b/2025/ocaml/lib/infrastructure/file_reader.ml deleted file mode 100644 index 7a80c0b..0000000 --- a/2025/ocaml/lib/infrastructure/file_reader.ml +++ /dev/null @@ -1,4 +0,0 @@ -let read_file filename = - let chan = In_channel.open_text filename in - let content = In_channel.input_all chan in - In_channel.close chan ; content diff --git a/2025/ocaml/lib/infrastructure/file_reader.mli b/2025/ocaml/lib/infrastructure/file_reader.mli deleted file mode 100644 index bb40577..0000000 --- a/2025/ocaml/lib/infrastructure/file_reader.mli +++ /dev/null @@ -1,3 +0,0 @@ -val read_file : string -> string -(** [read_file filename] is the contents of [filename] as a string. - The empty string is returned if [filename] does not exist. *) diff --git a/2025/ocaml/lib/presentation/cli.ml b/2025/ocaml/lib/presentation/cli.ml index fba98ae..e691545 100644 --- a/2025/ocaml/lib/presentation/cli.ml +++ b/2025/ocaml/lib/presentation/cli.ml @@ -1,10 +1,10 @@ let run_day = function | 1 -> - let content = - Infrastructure.File_reader.read_file "../_input/day_01.txt" - in - let answer = Application.D01p01.solve content () in - Logs.app (fun m -> m "%d" answer) ; + let content = Infrastructure.File.read "../_input/day_01.txt" in + let answerP1 = Application.D01p01.solve content () in + Logs.app (fun m -> m "D1P1=%d" answerP1) ; + let answerP2 = Application.D01p02.solve content () in + Logs.app (fun m -> m "D1P2=%d" answerP2) ; 0 | _ -> failwith "day not implemented" -- cgit v1.2.3