funkywork / nightmare

A set of components that fit, a priori, relatively well with the web framework (OCaml) Dream to try to build, at best, and quickly, dynamic web applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nightmare_tyxml: unnecessary complexity of `XXX_of`.

xhtmlboi opened this issue · comments

At the moment, the construction of a tag taking an endpoint seems to me too heavily complex. You have to repeat tags taking src, href and co, whereas it would be enough to do a_href_of endpoint continuation and a_src_of endpoint continuation and not have to reproduce each tag.

In many cases your approach works, but unfortunately not for cases where it is necessary to generate two attributes. For example, form where the method, in addition to the action, is induced by the type of the endpoint.
Producing a list of attributes would be quite annoying because it would force you to write the form call in this way:

Tyxml.Html.form ~a:(a_method_of endpoint :: a_action_of endpoint continuation :: []) []
(* Or supposing that [a_method_of] returns a list of attrib including the method. *)
Tyxml.Html.form ~a:(method_of enpoint @ []) []

Both suggestion seems heavy on the user-space.

That's fine for now :) and as the hardest (and most boring) part has been done by @xvw, I'll close the exit.