My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

clean up comparison operator

+12 -21
+12 -21
ocaml-tomlt/lib/tomlt.ml
··· 56 56 else kind ^ " " ^ to_string sort 57 57 end 58 58 59 - (* ---- Helpers ---- *) 60 - 61 - (* Result syntax for cleaner monadic chaining *) 62 - module Result_syntax = struct 63 - let ( let* ) = Result.bind 64 - let ( let+ ) r f = Result.map f r 65 - end 66 - 67 - (* Chain comparisons: return first non-zero, or final comparison *) 68 - let ( <?> ) c lazy_c = if c <> 0 then c else Lazy.force lazy_c 59 + let ( <?> ) c c' = if c <> 0 then c else c' 69 60 70 61 (* Find first char matching predicate *) 71 62 let string_index_opt p s = ··· 102 93 | UTC, Offset _ -> -1 103 94 | Offset _, UTC -> 1 104 95 | Offset { hours = h1; minutes = m1 }, Offset { hours = h2; minutes = m2 } -> 105 - Int.compare h1 h2 <?> lazy (Int.compare m1 m2) 96 + Int.compare h1 h2 <?> Int.compare m1 m2 106 97 107 98 let to_string = function 108 99 | UTC -> "Z" ··· 136 127 137 128 let compare a b = 138 129 Int.compare a.year b.year 139 - <?> lazy (Int.compare a.month b.month) 140 - <?> lazy (Int.compare a.day b.day) 130 + <?> Int.compare a.month b.month 131 + <?> Int.compare a.day b.day 141 132 142 133 let to_string d = Printf.sprintf "%04d-%02d-%02d" d.year d.month d.day 143 134 ··· 171 162 172 163 let compare a b = 173 164 Int.compare a.hour b.hour 174 - <?> lazy (Int.compare a.minute b.minute) 175 - <?> lazy (Int.compare a.second b.second) 176 - <?> lazy (Float.compare a.frac b.frac) 165 + <?> Int.compare a.minute b.minute 166 + <?> Int.compare a.second b.second 167 + <?> Float.compare a.frac b.frac 177 168 178 169 (* Remove trailing zeros from a string, keeping at least one char *) 179 170 let rstrip_zeros s = ··· 221 212 222 213 let compare a b = 223 214 Date.compare a.date b.date 224 - <?> lazy (Time.compare a.time b.time) 225 - <?> lazy (Tz.compare a.tz b.tz) 215 + <?> Time.compare a.time b.time 216 + <?> Tz.compare a.tz b.tz 226 217 227 218 let to_string dt = 228 219 Printf.sprintf "%sT%s%s" ··· 233 224 let pp fmt dt = Format.pp_print_string fmt (to_string dt) 234 225 235 226 let of_string s = 236 - let open Result_syntax in 227 + let open Result.Syntax in 237 228 match find_datetime_sep s with 238 229 | None -> Error "missing date/time separator" 239 230 | Some idx -> ··· 266 257 let equal a b = Date.equal a.date b.date && Time.equal a.time b.time 267 258 268 259 let compare a b = 269 - Date.compare a.date b.date <?> lazy (Time.compare a.time b.time) 260 + Date.compare a.date b.date <?> Time.compare a.time b.time 270 261 271 262 let to_string dt = 272 263 Printf.sprintf "%sT%s" (Date.to_string dt.date) (Time.to_string dt.time) ··· 274 265 let pp fmt dt = Format.pp_print_string fmt (to_string dt) 275 266 276 267 let of_string s = 277 - let open Result_syntax in 268 + let open Result.Syntax in 278 269 match find_datetime_sep s with 279 270 | None -> Error "missing date/time separator" 280 271 | Some idx ->