Skip to content

Commit

Permalink
No more let%map
Browse files Browse the repository at this point in the history
  • Loading branch information
drewolson committed Jan 8, 2024
1 parent 825a84f commit 8fde863
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions bin/main.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
module Syntax = struct
include Command.Param

let ( let+ ) = Command.Let_syntax.( >>| )
let ( and+ ) = Command.Let_syntax.Let_syntax.both
end

module IntSet = Set.Make (Int)

let years = IntSet.of_list [ 2022; 2023 ]
Expand All @@ -24,16 +31,17 @@ let part_arg =
;;

let run_command =
let%map_open.Command year =
let open Syntax in
let+ year =
flag
"year"
(optional_with_default 2023 year_arg)
~aliases:[ "y" ]
~doc:"int year to run (default: 2023)"
and day = flag "day" (required day_arg) ~aliases:[ "d" ] ~doc:"int day to run (1 - 25)"
and part =
and+ day = flag "day" (required day_arg) ~aliases:[ "d" ] ~doc:"int day to run (1 - 25)"
and+ part =
flag "part" (required part_arg) ~aliases:[ "p" ] ~doc:"int part to run (1 or 2)"
and bench = flag "bench" no_arg ~aliases:[ "b" ] ~doc:"benchmark solution" in
and+ bench = flag "bench" no_arg ~aliases:[ "b" ] ~doc:"benchmark solution" in
fun _ -> Runner.run year day part bench
;;

Expand Down
2 changes: 1 addition & 1 deletion lib/year2023/day06.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let data_p p =
;;

let races_p =
let%map times, distances = data_p P.integer in
let+ times, distances = data_p P.integer in
[ times; distances ]
|> List.transpose_exn
|> List.filter_map ~f:(function
Expand Down

0 comments on commit 8fde863

Please sign in to comment.