Repository navigation
Conversation
b3fcdf7 to
07b0fa5
Compare
lyrm
left a comment
There was a problem hiding this comment.
Hi! First, a rebase is needed.
Otherwise, I think you can go further and get rid of the closures in the main type t:
(Warning: the following code might contain typos; it is just an example)
type t = {
init_cache : bool;
write : sample -> unit;
persist_logs : log:Logs.t -> unit;
}and replace it with something like
type t =
| Perf of Performance.t
| Behav of Behavior.t
| Bench of Benchmark.tThis will avoid having to build the closures and make the code cleaner and easier to read. Ideally the with_channels would look like the following (I dropped the unused labelled arguments):
let with_channels backend ~data_dir ~merlin ~proj_paths f =
match backend with
| Performance ->
Performance.with_channels ~data_dir ~merlin ~proj_paths (fun p -> f (Perf p))
| Behavior config ->
Behavior.with_channels config ~data_dir (fun b -> f (Behav b))
| Benchmark ->
Benchmark.with_channels ~data_dir ~merlin (fun b -> f (Bench b))and write becomes:
let write t sample =
match t with
| Perf p -> Performance.write_analysis_data p sample
| Behav b -> Behavior.write_analysis_data b sample
| Bench b -> Benchmark.write_analysis_data b sampleor with the current type of write_analysis_data function (without the useless labelled arguments):
let write t { id; responses; cmd; file; loc; query_type } =
match t with
| Perf p -> Performance.write_analysis_data ~id ~responses ~cmd ~file ~loc ~query_type p
| Behav b -> Behavior.write_analysis_data ~id ~responses ~cmd b
| Bench b -> Benchmark.write_analysis_data ~id ~responses ~cmd ~query_type b
Also all backends' t have two common fields: commands, logs. Does it simplify the code to put them together ?
| commands : out_channel; | ||
| logs : out_channel; |
There was a problem hiding this comment.
All backends have a commands and a logs field. Could we put them together to make some things cleaner ? I am unsure about that; this needs to be checked and thought through!.
Addresses review feedback on tarides#78: - Replace closure-based Data.t with variant type (Perf | Behav | Bench) - Pass sample directly to write_analysis_data instead of individual labelled fields - Clean up unused labelled arguments in Behavior.with_channels and Benchmark.with_channels
07b0fa5 to
04877f0
Compare
This Pr tries to answer to the second point on #70
Previously we had a module Backend, and Data was another module which had a functor wrapped around Backend.
the backend was chosen via cli and main.ml will pack them into modules and then workflows.ml will then unpack the value and instantiate the functor.
now, Backend is deleted, and Data is now a single, ordinary module using a variant for the backends and standard functions to achieve the rest.