package incr_dom_sexp_form

  1. Overview
  2. Docs

This is a module for building forms that allow the user to edit complicated types (for example, configs).

'a Sexp_form.t gives you a form for editing values of type 'a.

It is called Sexp_form because it relies on the fact that 'a can be represented as a sexp. Specifically, it is capable of parsing the sexp representation of 'a to fill out the default values for the fields of the form automatically.

This means that if you have a type 'a which defines sexp_of_a, you can specify a default value of type 'a when rendering the 'a Sexp_form.t.

Sexp_form has other useful functionality beyond just parsing default values.

For example, list : 'a Sexp_form.t -> 'a list Sexp_form.t converts a form for editing 'a into a form for editing 'a list.

This gives the user buttons to add and delete elements and remembers deleted elements so that the user can undo.

Note: If you can't convert 'a to a sexp, you can still construct a 'a Sexp_form.t. You will just be unable to specify default values for the form.

type 'a t
val simple : 'a t
val with_default : sexp_of_t:('a -> Core.Sexp.t) -> default:'a -> diff:(original:Core.Sexp.t -> updated:Core.Sexp.t -> Incr_dom.Vdom.Node.t) -> ?between:Incr_dom.Vdom.Node.t -> unit -> 'a t

Used to display default as the initial value of your sexp_form. Also displays diff for the user to understand how the values entered into the form differ from the default value. between is a node which will be displayed between the form and the diff.

val no_diff : original:Core.Sexp.t -> updated:Core.Sexp.t -> Incr_dom.Vdom.Node.t

no_diff produces an empty Node.t.