The functorial interface
TyXML provides a functorial interface to implement HTML and SVG on top of any XML implementations. This is used heavily by Eliom to implement the F and D modules, providing respectivelly a functionnal and a DOM version of the HTML implementation.
The Make functors ¶
Those interfaces are available in the modules Html5_f and Svg_f. They provide a functor Make which takes a concrete implementation of Xml following Xml_sigs.T. A default implementation is provided by the Xml module. The functor Html5_f.Make also needs an Svg implementation that you can obtain, for example, with the functor Svg_f.Make. Due to typing constraints (see next section), The Xml implementation will always need to provide an
'a wrap = 'a
Wrapping up the nodes ¶
Beside the #Make functor. those two modules provide a MakeWrapped functor, which allows to wrap Xml elements in a monad. A good example of application is the R modules with reactive nodes in eliom. Here is the simplified signature of
'a elt list signal -> div elt
will wrap the input of every Xml nodes and be integrated in the resulting node.
In order to do this, You need to provide an additional Wrap module to the functor, following the signature Xml_wrap.T. This implements monadic operations, with multiple
An identity wrapper, Xml_wrap.NoWrap, is provided. The Make functor is only MakeWrapped# partially applied to NoWrap.