in newt.mli: type 'a component val form_add_component : [> `Form ] component -> [> `Component ] component -> unit val form_add_components : [> `Form ] component -> [> `Component ] component list -> unit in newt.ml: type 'a component = { co : newtComponent; (* The component. *) mutable in_form : bool; (* If added to a form, this is set. *) } let form_add_component form co = if co.in_form then failwith "component can only be added to a single form"; newtFormAddComponent form.co co.co; co.in_form <- true let form_add_components form components = List.iter (fun co -> form_add_component form co) components in 04_form.ml: let text = textbox 1 1 15 5 [WRAP; SCROLL] in textbox_set_text text "This is some text in a reflowed text box. This is some text in a reflowed text box."; let b1 = button 5 8 " OK " in let b2 = button 5 13 "Cancel" in let form = form None None [] in form_add_components form [text; b1; b2];