In the Map case, clearly the value type is not speficified, but I’m happy to reify it into module with a concrete type of char option CharMap.t.
I already use ppx_deriving for my own types, so usage of that is preferred if it can be done concisely. Per ppx_deriving#working-with-existing-types it should be feasible, but I’m wresting enough to request assistance. Will be trying to grok the following threads in the interim.
Which… makes sense. Could be pretty slick if the some sort of derivation/lookup occurred and was substituted in once traversal detected types w/ adequate printers, but that seems like a pretty advanced ask/task. The type system perhaps hasn’t even started its great work by the time this codegen takes place. I suspect such a feature may not even be feasible.
The containers stdlib extension makes this almost effortless:
open Containers
module Signals = Set.Make(Char)
let () = Format.printf "my set: %a" (Signals.pp Char.pp) @@ Signals.of_list ['a']
“Almost”, because the pp on Set, Map, etc needs to be parameterized by the value in question; but you can prefill that to make e.g. nested/recursive usage fit together nicely:
module Signals = struct
module M = Set.Make (Char)
include M
let pp = M.pp Char.pp
end
let () =
Format.printf "my set: %a" Signals.pp @@ Signals.of_list ['a']