ppxlib
ppxlib copied to clipboard
Allow arguments of derivers to have default values
Deriving arguments are always extracted as options, or bool: see the two function creating arguments: arg and flag.
It could be nice to add a function to have an argument with a default value, to avoid handling the default case in the main function, as in let arg = match arg with Some v -> v | None -> default_value in (reported by @sim642, see https://github.com/ocaml-ppx/ppx_deriving/pull/263#discussion_r924307827).
The added function would be:
val arg_default :
string ->
(expression, 'a -> 'a, 'a) Ast_pattern.t ->
default:'a ->
'a param
@Annosha is working on this one