Skip to content

Commit

Permalink
Fixed Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenldl committed Jan 15, 2022
1 parent 41e9385 commit 9ae1d61
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ RUN opam install dune containers fmt
RUN opam install mparser re ptime oseq seq diet
RUN opam install yojson fileutils
RUN opam install utop ocamlformat
RUN opam install alcotest crowbar
RUN opam install js_of_ocaml js_of_ocaml-ppx lwt_ppx
RUN opam install js_of_ocaml-lwt qcheck qcheck-alcotest
8 changes: 4 additions & 4 deletions src/pattern_resolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ module Search_param = struct
Timedesc.Time_zone.make_offset_only_exn search_using_offset_from_utc
in
let start_dt =
CCOpt.get_exn_or
CCOption.get_exn_or
"Expected successful date time construction from timestamp"
@@ Timedesc.of_timestamp ~tz_of_date_time start
in
let end_inc_dt =
CCOpt.get_exn_or
CCOption.get_exn_or
"Expected successful date time construction from timestamp"
@@ Timedesc.of_timestamp ~tz_of_date_time (Timedesc.Span.pred end_exc)
in
Expand Down Expand Up @@ -523,13 +523,13 @@ let resolve (search_param : Search_param.t) (t : Pattern.t) :
x'
|> Branch.to_date_time
~offset_from_utc:search_param.search_using_offset_from_utc
|> CCOpt.map Timedesc.to_timestamp_single
|> CCOption.map Timedesc.to_timestamp_single
in
let y =
y'
|> Branch.to_date_time
~offset_from_utc:search_param.search_using_offset_from_utc
|> CCOpt.map Timedesc.to_timestamp_single
|> CCOption.map Timedesc.to_timestamp_single
in
match (x, y) with
| Some x, Some y -> Some (x, y)
Expand Down
14 changes: 7 additions & 7 deletions src/points.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ let make ?tz ?offset_from_utc ?year ?month ?day ?weekday ?hour ?minute ?second
| Error (`Invalid_offset tz_offset) | Error (`Unrecorded_offset tz_offset)
->
Error
(`Invalid_tz_info (CCOpt.map Timedesc.Time_zone.name tz, tz_offset))
(`Invalid_tz_info (CCOption.map Timedesc.Time_zone.name tz, tz_offset))
in
match tz_info with
| Error e -> Error e
Expand All @@ -117,20 +117,20 @@ let make ?tz ?offset_from_utc ?year ?month ?day ?weekday ?hour ?minute ?second
in
if not year_is_fine then
Error
(`Invalid_year (CCOpt.get_exn_or "Expected year to be Some _" year))
(`Invalid_year (CCOption.get_exn_or "Expected year to be Some _" year))
else if not month_day_is_fine then
Error (`Invalid_day (CCOpt.get_exn_or "Expected day to be Some _" day))
Error (`Invalid_day (CCOption.get_exn_or "Expected day to be Some _" day))
else if not hour_is_fine then
Error
(`Invalid_hour (CCOpt.get_exn_or "Expected hour to be Some _" hour))
(`Invalid_hour (CCOption.get_exn_or "Expected hour to be Some _" hour))
else if not minute_is_fine then
Error
(`Invalid_minute
(CCOpt.get_exn_or "Expected minute to be Some _" minute))
(CCOption.get_exn_or "Expected minute to be Some _" minute))
else if not second_is_fine then
Error
(`Invalid_second
(CCOpt.get_exn_or "Expected second to be Some _" second))
(CCOption.get_exn_or "Expected second to be Some _" second))
else
let default_month =
match lean_toward with `Earlier -> 1 | `Later -> 12
Expand Down Expand Up @@ -537,7 +537,7 @@ let equal_pick t1 t2 =

let equal x y =
equal_pick x.pick y.pick
&& CCOpt.equal Timedesc.Time_zone_info.equal x.tz_info y.tz_info
&& CCOption.equal Timedesc.Time_zone_info.equal x.tz_info y.tz_info

let to_pattern ({ pick; tz_info = _ } : t) =
let years =
Expand Down
14 changes: 7 additions & 7 deletions src/resolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ let do_chunk_at_year_boundary tz (s : Time.Interval'.t Seq.t) =
| Seq.Nil -> Seq.empty
| Seq.Cons ((t1, t2), rest) ->
let dt1 =
CCOpt.get_exn_or "Expected successful date time construction"
CCOption.get_exn_or "Expected successful date time construction"
@@ Timedesc.of_timestamp ~tz_of_date_time:tz t1
in
let dt2 =
t2
|> Timedesc.Span.pred
|> Timedesc.of_timestamp ~tz_of_date_time:tz
|> CCOpt.get_exn_or "Expected successful date time construction"
|> CCOption.get_exn_or "Expected successful date time construction"
in
let dt1_year = Timedesc.year dt1 in
if dt1_year = Timedesc.year dt2 then fun () ->
Expand All @@ -325,15 +325,15 @@ let do_chunk_at_month_boundary tz (s : Time.Interval'.t Seq.t) =
| Seq.Nil -> Seq.empty
| Seq.Cons ((t1, t2), rest) ->
let dt1 =
CCOpt.get_exn_or "Expected successful date time construction"
CCOption.get_exn_or "Expected successful date time construction"
@@ Timedesc.of_timestamp ~tz_of_date_time:tz t1
in
let dt1_year = Timedesc.year dt1 in
let dt2 =
t2
|> Timedesc.Span.pred
|> Timedesc.of_timestamp ~tz_of_date_time:tz
|> CCOpt.get_exn_or "Expected successful date time construction"
|> CCOption.get_exn_or "Expected successful date time construction"
in
if
dt1_year = Timedesc.year dt2
Expand Down Expand Up @@ -493,7 +493,7 @@ and skip_points_in_p1 ~last_start2 ~(rest1 : timestamp Seq.t) ~(p1 : Points.t)

and aux_pattern_intervals ~search_space search_using_tz mode bound p1 p2 =
let _, search_space_end_exc =
CCOpt.get_exn_or "Expected successful retrieval of last element in list"
CCOption.get_exn_or "Expected successful retrieval of last element in list"
@@ Misc_utils.last_element_of_list search_space
in
let rec aux_pattern_intervals' s1 s2 space1 space2 p1 p2 =
Expand Down Expand Up @@ -574,11 +574,11 @@ and aux_inter search_using_tz timeres =
let rec aux_inter' ~start (timeres : t list) =
let interval_batches = resolve ~start search_using_tz timeres in
let batch_for_sampling = collect_batch interval_batches in
if List.exists CCOpt.is_none batch_for_sampling then Seq.empty
if List.exists CCOption.is_none batch_for_sampling then Seq.empty
else
let batch_for_sampling =
CCList.map
(CCOpt.get_exn_or "Unexpected None in batch_for_sampling")
(CCOption.get_exn_or "Unexpected None in batch_for_sampling")
batch_for_sampling
in
match batch_for_sampling with
Expand Down
2 changes: 1 addition & 1 deletion src/seq_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let collect_round_robin (type a) ~(f_le : a -> a -> bool)
| Seq.Cons (x, rest) -> (Some x, Some x :: acc, rest :: new_batches))
(cur, [], []) batches
in
if List.exists CCOpt.is_some acc then
if List.exists CCOption.is_some acc then
let acc = List.rev acc in
let new_batches = List.rev new_batches in
fun () -> Seq.Cons (acc, aux cur new_batches)
Expand Down
8 changes: 4 additions & 4 deletions src/time.ml
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ module Range = struct
let x = int_exc_range_of_range ~to_int x |> timestamp_pair_of_int_pair in
let y = int_exc_range_of_range ~to_int y |> timestamp_pair_of_int_pair in
Interval'.join x y
|> CCOpt.map (fun (x, y) ->
|> CCOption.map (fun (x, y) ->
`Range_exc
( of_int @@ Timedesc.Span.get_ns_offset x,
of_int @@ Timedesc.Span.get_ns_offset @@ y ))
Expand Down Expand Up @@ -841,7 +841,7 @@ module Weekday_ranges = Ranges.Make (struct
let of_int x =
x
|> Timedesc.Utils.weekday_of_tm_int
|> CCOpt.get_exn_or "Expected successful construction of weekday"
|> CCOption.get_exn_or "Expected successful construction of weekday"
end)

module Month_day_ranges = Ranges.Make (struct
Expand Down Expand Up @@ -1245,7 +1245,7 @@ let pattern_intervals ?(inc_exc : inc_exc = `Exc)
in
if Points.precision start < Points.precision end_ then
invalid_arg "pattern_intervals: start is less precise than end_exc";
if CCOpt.equal Timedesc.Time_zone_info.equal start.tz_info end_.tz_info then
if CCOption.equal Timedesc.Time_zone_info.equal start.tz_info end_.tz_info then
match (start.pick, end_.pick) with
| Points.(N ns_start, N ns_end) when ns_start = ns_end -> always
| Points.(
Expand Down Expand Up @@ -1495,7 +1495,7 @@ let month_of_full_string s : int option =
| _ -> None

let abbr_string_of_month (month : int) : string option =
CCOpt.map (fun s -> String.sub s 0 3) (full_string_of_month month)
CCOption.map (fun s -> String.sub s 0 3) (full_string_of_month month)

let month_of_abbr_string s : int option =
match s with
Expand Down
4 changes: 2 additions & 2 deletions src/to_sexp.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let sexp_of_month x =
CCSexp.atom
@@ CCOpt.get_exn_or "Expected valid month"
@@ CCOption.get_exn_or "Expected valid month"
@@ Time.abbr_string_of_month x

let sexp_of_weekday x = CCSexp.atom @@ Time.abbr_string_of_weekday x
Expand Down Expand Up @@ -84,7 +84,7 @@ let sexp_of_points ({ pick; tz_info } : Points.t) =
sexp_of_int second;
sexp_of_int ns;
])));
CCOpt.map Timedesc.Time_zone_info.to_sexp tz_info;
CCOption.map Timedesc.Time_zone_info.to_sexp tz_info;
])

let sexp_of_date_time = Timedesc.to_sexp
Expand Down

0 comments on commit 9ae1d61

Please sign in to comment.