diff options
author | Adam Chlipala <adam@chlipala.net> | 2011-09-03 12:51:05 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2011-09-03 12:51:05 -0400 |
commit | 50fc58e8fc815053950b7b919a75cb363d83f114 (patch) | |
tree | d792d445b5fbc6b0a16eadef95d70510f9037dd6 /doc | |
parent | 22dca5aaa24df32b6b59b27b62944d28adcad9ca (diff) |
An abstract type of IDs
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual.tex | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/manual.tex b/doc/manual.tex index a3800e17..e6a96c05 100644 --- a/doc/manual.tex +++ b/doc/manual.tex @@ -1983,6 +1983,17 @@ $$\begin{array}{l} \mt{val} \; \mt{onMouseup} : \mt{transaction} \; \mt{unit} \to \mt{transaction} \; \mt{unit} \end{array}$$ +\subsubsection{Node IDs} + +There is an abstract type of node IDs that may be assigned to \cd{id} attributes of most HTML tags. + +$$\begin{array}{l} + \mt{type} \; \mt{id} \\ + \mt{val} \; \mt{fresh} : \mt{transaction} \; \mt{id} +\end{array}$$ + +The \cd{fresh} function is allowed on both server and client, but there is no other way to create IDs, which includes lack of a way to force an ID to match a particular string. The only semantic importance of IDs within Ur/Web is in uses of the HTML \cd{<label>} tag. IDs play a much more central role in mainstream JavaScript programming, but Ur/Web uses a very different model to enable changes to particular nodes of a page tree, as the next manual subsection explains. IDs may still be useful in interfacing with JavaScript code (for instance, through Ur/Web's FFI). + \subsubsection{Functional-Reactive Page Generation} Most approaches to ``AJAX''-style coding involve imperative manipulation of the DOM tree representing an HTML document's structure. Ur/Web follows the \emph{functional-reactive} approach instead. Programs may allocate mutable \emph{sources} of arbitrary types, and an HTML page is effectively a pure function over the latest values of the sources. The page is not mutated directly, but rather it changes automatically as the sources are mutated. |