ppxlib icon indicating copy to clipboard operation
ppxlib copied to clipboard

Allow arguments of derivers to have default values

Open panglesd opened this issue 2 years ago • 1 comments

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

panglesd avatar Mar 23 '23 09:03 panglesd

@Annosha is working on this one

panglesd avatar Mar 24 '23 06:03 panglesd