c4-project / c4f

The C4 Concurrent C Fuzzer
MIT License
13 stars 1 forks source link

Make Env-taking generators standalone functions #250

Open MattWindsor91 opened 3 years ago

MattWindsor91 commented 3 years ago

A common pattern in the codebase these days is:

module Foo (Env : Env_types.S) = struct
  let quickcheck_generator = (* ... *)
  (* ... *)
end

let gen_foo env =
  let module F = Foo (struct let env = env end) in quickcheck_generator

This is unnecessarily inducing a lot of module boilerplate we don't need, because we could rewrite to:

let gen_foo (env : Env.t) = (* ... *)

module Foo (Env : Env_types.S) = struct
  let quickcheck_generator = gen_foo Env.env
  (* ... *)
end