A fork of mtelver's day10 project
at main 14 lines 483 B view raw
1type package_list = { 2 packages: string list; 3} [@@deriving yojson] 4 5let read_packages filename = 6 let json = Yojson.Safe.from_file filename in 7 match package_list_of_yojson json with 8 | Ok { packages } -> packages 9 | Error msg -> failwith (Printf.sprintf "Failed to parse package list from %s: %s" filename msg) 10 11let write_packages filename packages = 12 let package_list = { packages } in 13 let json = package_list_to_yojson package_list in 14 Yojson.Safe.to_file filename json