- Simplify `.ocamlformat` to use `default` profile with fewer overrides - Extract shared types and utilities into a `remind_sync` library (`icalendar_augmented`, `ptime_augmented`, `timedesc_augmented`, `result_augmented`, `utf8`) - Replace `eventTransformer.ml` and the predicate system in `eventPredicates.ml` with a sequential collector pipeline (`collect_uuid`, `collect_summary`, `collect_start_end_duration`, etc.) - Simplify `Remind.rem` to a flat record with `Timedesc` date/time fields and replace `rem_to_string` with a leaner `string_of_rem` - Add `separate_master_and_recurrence` and `get_recurrence_id` helpers to `utils.ml` - Wire `main.ml` to call `EventPredicates.remind_of_event` per UID group and print results directly - Remove `eventTransformer` module from `bin/dune` and enable the `remind_sync` library dependency
43 lines
1.1 KiB
OCaml
43 lines
1.1 KiB
OCaml
module Internal_result = struct
|
|
type ('a, 'b) t = ('a, 'b) result = Ok of 'a | Error of 'b
|
|
|
|
let return x = Ok x
|
|
let error e = Error e
|
|
let error_string s = Error (`Error_message s)
|
|
let bind = Stdlib.Result.bind
|
|
let ok = Result.ok
|
|
|
|
module List = struct
|
|
let map (xs : 'a list) ~(f : 'a -> ('b, 'c) t) : ('b list, 'c) t =
|
|
let rec loop ?(acc = []) xs =
|
|
match xs with
|
|
| [] -> return (List.rev acc)
|
|
| hd :: tl -> (
|
|
match f hd with
|
|
| Ok x -> loop ~acc:(x :: acc) tl
|
|
| Error e -> Error e)
|
|
in
|
|
loop xs
|
|
|
|
let iteri ?(start = 0) (xs : 'a list) ~(f : int -> 'a -> (unit, 'b) t) : (unit, 'b) t =
|
|
let rec loop ?(idx = start) xs =
|
|
match xs with
|
|
| [] -> return ()
|
|
| hd :: tl -> begin
|
|
let res = f idx hd in
|
|
match res with
|
|
| Ok () -> loop ~idx:(idx + 1) tl
|
|
| Error e -> Error e
|
|
end
|
|
in
|
|
loop xs
|
|
end
|
|
|
|
module Let_syntax = struct
|
|
let ( let* ) = Stdlib.Result.bind
|
|
let ( let+ ) x f = Stdlib.Result.map f x
|
|
end
|
|
end
|
|
|
|
include Internal_result
|