package incr_dom_widgets

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Build a form for a record directly, in the same manner as Record_builder or Profunctor.

e.g.

let animal_form : (Animal.t, Animal.t, string Id.t * (bool Id.t * unit)) t =
  Form.Description.Of_record.build_for_record (
    Animal.Fields.make_creator
      ~species:(field Form.Description.string)
      ~can_quack:(field Form.Description.bool))
;;

Is equivalent† to:

let animal_form : (Animal.t, Animal.t, string Id.t * (bool Id.t * unit)) t =
  let open Form.Description in
  map (
    both (contra_map ~f:Animal.species string) @@
    both (contra_map ~f:Animal.can_quack bool) @@
    Hlist.nil)
    ~f:(fun (species, (can_quack, ())) -> { Animal.species; can_quack; })
;;

† except that there is no risk of name shadowing as there would be here, but I wrote the local open only for brevity.

module Make_creator_types : sig ... end

These are the types used for building a form by combining record fields.

val field : ('field, 'field, 'field_ids) t -> ('record, 'field) Core_kernel.Field.t -> ('field, 'field_ids, _, _, _, _, 'record) Make_creator_types.handle_one_field

Handle one field of a record using the supplied editor.

This should be used as an argument to Fields.make_creator, see the example.

val build_for_record : (_, 'ids, 'record) Make_creator_types.handle_all_fields -> ('record, 'record, 'ids) t

Build the form for a whole record.

This is used with an application of Fields.make_creator as shown in the example.