Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove a bunch of useless "let open Memo.O in" #11086

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions src/dune_rules/artifact_substitution.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Import
open Memo.O

(* Artifact substitutions works as follow: the substitution is encoded as a
string of the form:
Expand Down Expand Up @@ -94,7 +95,6 @@ module Conf = struct
;;

let sign_hook_of_context (context : Context.t) =
let open Memo.O in
let+ config =
let+ ocaml = Context.ocaml context in
ocaml.ocaml_config
Expand All @@ -116,7 +116,6 @@ module Conf = struct
;;

let of_context (context : Context.t) =
let open Memo.O in
let get_vcs = Source_tree.nearest_vcs in
let name = Context.name context in
let get_location = Install.Paths.get_local_location name in
Expand All @@ -139,7 +138,6 @@ module Conf = struct
;;

let of_install ~relocatable ~roots ~(context : Context.t) =
let open Memo.O in
let get_vcs = Source_tree.nearest_vcs in
let hardcoded_ocaml_path =
match relocatable with
Expand Down Expand Up @@ -194,7 +192,6 @@ let eval t ~(conf : Conf.t) =
let relocatable path =
(* return a relative path to the install directory in case of relocatable
instead of absolute path *)
let open Memo.O in
conf.hardcoded_ocaml_path
>>| function
| Hardcoded _ -> Path.to_absolute_filename path
Expand All @@ -205,8 +202,7 @@ let eval t ~(conf : Conf.t) =
Fiber.return (Array.make n s |> Array.to_list |> String.concat ~sep:"")
| Vcs_describe p ->
Memo.run
(let open Memo.O in
conf.get_vcs p
(conf.get_vcs p
>>= function
| None -> Memo.return ""
| Some vcs ->
Expand All @@ -215,21 +211,19 @@ let eval t ~(conf : Conf.t) =
| Location (name, lib_name) ->
conf.get_location name lib_name |> relocatable |> Memo.run
| Configpath d ->
let open Memo.O in
(let* dir = conf.get_config_path d in
match dir with
| None -> Memo.return None
| Some dir -> relocatable dir >>| Option.some)
>>| Option.value ~default:""
|> Memo.run
| Hardcoded_ocaml_path ->
(let open Memo.O in
conf.hardcoded_ocaml_path
>>| function
| Relocatable _ -> "relocatable"
| Hardcoded l ->
let l = List.map l ~f:Path.to_absolute_filename in
"hardcoded\000" ^ String.concat ~sep:"\000" l)
conf.hardcoded_ocaml_path
>>| (function
| Relocatable _ -> "relocatable"
| Hardcoded l ->
let l = List.map l ~f:Path.to_absolute_filename in
"hardcoded\000" ^ String.concat ~sep:"\000" l)
|> Memo.run
;;

Expand Down
2 changes: 0 additions & 2 deletions src/dune_rules/artifacts_db.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ let available_exes ~dir (exes : Executables.t) =
~forbidden_libraries:exes.forbidden_libraries
~allow_overlaps:exes.buildable.allow_overlapping_dependencies
in
let open Memo.O in
let+ available = Lib.Compile.direct_requires compile_info in
Resolve.is_ok available
;;

let get_installed_binaries ~(context : Context.t) stanzas =
let merge _ x y = Some (Appendable_list.( @ ) x y) in
let open Memo.O in
Memo.List.map stanzas ~f:(fun d ->
let dir = Path.Build.append_source (Context.build_dir context) (Dune_file.dir d) in
let* expander = Expander0.get ~dir in
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/blang_expand.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open Import
open Memo.O

let rec eval (t : Blang.t) ~dir ~f =
let open Memo.O in
match t with
| Const x -> Memo.return x
| Expr sw ->
Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/buildable_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ let ocaml_flags t ~dir (spec : Ocaml_flags.Spec.t) =
;;

let gen_select_rules sctx ~dir compile_info =
let open Memo.O in
Lib.Compile.resolved_selects compile_info
|> Resolve.Memo.read_memo
>>= Memo.parallel_iter ~f:(fun { Lib.Compile.Resolved_select.dst_fn; src_fn } ->
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/cinaps.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Import
open Memo.O

type t =
{ loc : Loc.t
Expand Down Expand Up @@ -75,7 +76,6 @@ let () =
;;

let gen_rules sctx t ~dir ~scope =
let open Memo.O in
let loc = t.loc in
(* Files checked by cinaps *)
let* cinapsed_files =
Expand Down
3 changes: 1 addition & 2 deletions src/dune_rules/compilation_context.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Import
open Memo.O

module Includes = struct
type t = Command.Args.without_targets Command.Args.t Lib_mode.Cm_kind.Map.t
Expand Down Expand Up @@ -145,7 +146,6 @@ let create
?loc
()
=
let open Memo.O in
let project = Scope.project scope in
let context = Super_context.context super_context in
let* ocaml = Context.ocaml context in
Expand Down Expand Up @@ -325,7 +325,6 @@ let entry_module_names sctx t =
match Lib_info.entry_modules (Lib.info t) with
| External d -> Resolve.Memo.of_result d
| Local ->
let open Memo.O in
let+ modules = Dir_contents.modules_of_lib sctx t in
let modules = Option.value_exn modules in
Resolve.return (Modules.With_vlib.entry_modules modules |> List.map ~f:Module.name)
Expand Down
3 changes: 1 addition & 2 deletions src/dune_rules/cond_expand.ml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
open! Stdune
open! Import
open Memo.O

let eval (cond : Dune_lang.Cond.t) ~dir ~f =
let open Memo.O in
let expand_sw = String_expander.Memo.expand ~mode:Single ~dir ~f in
let* from_case =
Memo.List.find_map cond.cases ~f:(fun (blang, sw) ->
Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/cram/cram_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ let collect_stanzas =
;;

let rules ~sctx ~dir tests =
let open Memo.O in
let* stanzas = collect_stanzas ~dir
and* with_package_mask =
Dune_load.mask ()
Expand Down
3 changes: 1 addition & 2 deletions src/dune_rules/ctypes/ctypes_rules.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Import
open Memo.O

(* This module expands either a (library ... (ctypes ...)) rule or an
(executables ... (ctypes ...)) rule into the generated set of .ml and .c
Expand Down Expand Up @@ -295,7 +296,6 @@ let gen_rules ~cctx ~(buildable : Buildable.t) ~loc ~scope ~dir ~sctx =
let type_description_functor = ctypes.type_description.functor_ in
let c_types_includer_module = ctypes.generated_types in
let c_generated_types_module = Ctypes_field.c_generated_types_module ctypes in
let open Memo.O in
let foreign_archives_deps =
let { Lib_config.ext_lib; ext_dll; _ } =
(Compilation_context.ocaml cctx).lib_config
Expand Down Expand Up @@ -331,7 +331,6 @@ let gen_rules ~cctx ~(buildable : Buildable.t) ~loc ~scope ~dir ~sctx =
|> Memo.return
| Pkg_config ->
let+ () =
let open Memo.O in
let setup query =
let* res = Pkg_config.gen_rule sctx ~dir ~loc query in
match res with
Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/dep_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ let deps_of_vlib_module ({ obj_dir; vimpl; dir; sctx; _ } as md) ~ml_kind source
let impl = Vimpl.impl vimpl in
Dune_project.dune_version impl.project
in
let open Memo.O in
let+ deps = ooi_deps md ~dune_version ~vlib_obj_map ~ml_kind sourced_module in
Action_builder.map deps ~f:(List.map ~f:Modules.Sourced_module.to_module)
| Some lib ->
Expand Down
6 changes: 1 addition & 5 deletions src/dune_rules/dune_file.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Import
open Memo.O

type t =
{ dir : Path.Source.t
Expand Down Expand Up @@ -91,7 +92,6 @@ let rec parse_file_includes ~stanza_parser ~context sexps =
|> Memo.List.concat_map ~f:(fun stanza ->
match Stanza.repr stanza with
| Stanzas.Include.T (loc, fn) ->
let open Memo.O in
let* sexps, context = Include_stanza.load_sexps ~context (loc, fn) in
parse_file_includes ~stanza_parser ~context sexps
| _ -> Memo.return [ stanza ])
Expand All @@ -105,7 +105,6 @@ type eval =

let parse_stanzas ~file ~(eval : eval) sexps =
let warnings = Warning_emit.Bag.create () in
let open Memo.O in
let* stanzas =
let context =
Include_stanza.in_src_file
Expand Down Expand Up @@ -146,7 +145,6 @@ let parse_stanzas ~file ~(eval : eval) sexps =
;;

let parse sexps ~file ~(eval : eval) =
let open Memo.O in
let+ stanzas, dynamic_includes = parse_stanzas sexps ~file ~eval in
( { dir = eval.dir
; project = eval.project
Expand Down Expand Up @@ -180,7 +178,6 @@ let fold_static_stanzas t ~init ~f = Id_fold.fold_static_stanzas t ~init ~f
let to_dyn = Dyn.opaque

let find_stanzas t key =
let open Memo.O in
let+ stanzas = Memo.Lazy.force t.stanzas in
(* CR-rgrinberg: save a map to represent the stanzas to make this fast. *)
List.filter_map stanzas ~f:(Stanza.Key.get key)
Expand Down Expand Up @@ -293,7 +290,6 @@ end = struct
;;

let create_plugin_wrapper context ocaml_config ~exec_dir ~plugin ~wrapper ~target =
let open Memo.O in
let+ plugin_contents = Fs_memo.file_contents plugin in
Io.with_file_out (Path.build wrapper) ~f:(fun oc ->
write oc ~context ~ocaml_config ~target ~exec_dir ~plugin ~plugin_contents);
Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/dune_load.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module Source_tree_map_reduce =
Source_tree.Make_map_reduce_with_progress (Memo) (Projects_and_dune_files)

let load () =
let open Memo.O in
let status dir =
match Source_tree.Dir.status dir with
| Vendored -> `Vendored
Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/env_binaries.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ let expand_str_lazy expander sw =
match String_with_vars.text_only sw with
| Some s -> Memo.return s
| None ->
let open Memo.O in
let* expander = Memo.Lazy.force expander in
Expander.No_deps.expand_str expander sw
;;
Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/env_stanza_db.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module Node = struct
}

let by_context dir =
let open Memo.O in
let+ context = Context.DB.by_dir dir in
let { Context.Env_nodes.context; workspace } = Context.env_nodes context in
match context, workspace with
Expand Down
4 changes: 1 addition & 3 deletions src/dune_rules/exe.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Import
open Memo.O

module Program = struct
type t =
Expand Down Expand Up @@ -153,7 +154,6 @@ let link_exe
let exe = exe_path_from_name cctx ~name ~linkage in
let top_sorted_cms = Cm_files.top_sorted_cms cm_files ~mode in
let fdo_linker_script = Fdo.Linker_script.create cctx (Path.build exe) in
let open Memo.O in
let* action_with_targets =
let ocaml_flags = Ocaml_flags.get (Compilation_context.flags cctx) (Ocaml mode) in
let prefix =
Expand Down Expand Up @@ -266,7 +266,6 @@ let link_many
~promote
cctx
=
let open Memo.O in
let o_files =
match o_files with
| None -> Mode.Map.empty
Expand Down Expand Up @@ -361,7 +360,6 @@ let build_and_link_many
~promote
cctx
=
let open Memo.O in
let* () = Module_compilation.build_all cctx in
let* () =
Memo.when_ (Compilation_context.bin_annot cctx) (fun () ->
Expand Down
4 changes: 1 addition & 3 deletions src/dune_rules/fdo.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Import
open Memo.O

type phase =
| All
Expand Down Expand Up @@ -44,7 +45,6 @@ let ocamlfdo_binary sctx dir =
(* FDO flags are context dependent. *)
let get_flags var =
let f (ctx : Context.t) =
let open Memo.O in
let+ env = Context.installed_env ctx in
Env.get env var |> Option.value ~default:"" |> String.extract_blank_separated_words
in
Expand Down Expand Up @@ -165,7 +165,6 @@ module Linker_script = struct
| Some fdo_profile_path -> Command.Args.S [ A "-fdo-profile"; Dep fdo_profile_path ]
| None -> As []
in
let open Memo.O in
let ocamlfdo_binary = ocamlfdo_binary sctx dir in
let ocamlfdo_linker_script_flags =
Action_builder.of_memo @@ ocamlfdo_linker_script_flags ctx
Expand Down Expand Up @@ -202,7 +201,6 @@ module Linker_script = struct
;;

let flags t =
let open Memo.O in
let open Command.Args in
match t with
| None -> Memo.return (As [])
Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/fetch_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ let gen_rules_for_checksum_or_url (loc_url, (url : OpamUrl.t)) checksum =
action ~target ~kind:`File
|> Action_builder.With_targets.add ~file_targets:[ target ]
in
let open Memo.O in
let+ () = rule dir_rule
and+ () = rule file_rule in
()
Expand Down
3 changes: 1 addition & 2 deletions src/dune_rules/findlib.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Import
open Memo.O
module Opam_package = Package
module P = Ocaml.Variant
module Ps = Ocaml.Variant.Set
Expand Down Expand Up @@ -76,7 +77,6 @@ module DB = struct
let create ~paths ~(lib_config : Lib_config.t) =
let stdlib_dir = lib_config.stdlib_dir in
let ext_lib = lib_config.ext_lib in
let open Memo.O in
let+ builtins =
let version = lib_config.ocaml_version in
Meta.builtins ~stdlib_dir ~version
Expand Down Expand Up @@ -483,7 +483,6 @@ type t = DB.t
let create =
Per_context.create_by_name ~name:"findlib" (fun context ->
Memo.lazy_ (fun () ->
let open Memo.O in
let* context = Context.DB.get context in
let* paths = Context.findlib_paths context
and* lib_config =
Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/foreign_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ let foreign_flags_env =
let+ ocaml = Context.ocaml context in
default_context_flags (Context.build_context context) ocaml.ocaml_config ~project)
~f:(fun ~parent expander (env : Dune_env.config) ->
let open Memo.O in
let+ parent = parent in
let foreign_flags lang =
Foreign_language.Dict.get env.foreign_flags lang
Expand Down
Loading
Loading