/usr/share/doc/libghc-hsx-jmacro-doc/html/HSP-JMacro.html is in libghc-hsx-jmacro-doc 7.3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>HSP.JMacro</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_HSP-JMacro.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/HSP-JMacro.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hsx-jmacro-7.3.5: hsp+jmacro support</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr></table><p class="caption">HSP.JMacro</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This module provides support for:
</p><ol><li> embedding Javascript generated by JMacro into HSX.
</li><li> turning XML generated by HSX into a DOM node in Javascript
</li></ol><p>It provides the following instances:
</p><pre> instance (XMLGenerator m, IntegerSupply m) => EmbedAsChild m JStat
instance (IntegerSupply m, IsName n, EmbedAsAttr m (Attr Name String)) => EmbedAsAttr m (Attr n JStat)
instance ToJExpr XML
instance ToJExpr DOMNode
instance ToJExpr XMLToInnerHTML
instance ToJExpr XMLToDOM
</pre><p>In order to ensure that each embedded <code><a href="/usr/share/doc/libghc-jmacro-doc/html/Language-Javascript-JMacro.html#t:JStat">JStat</a></code> block has unique
variable names, the monad must supply a source of unique
names. This is done by adding an instance of <code><a href="HSP-JMacro.html#t:IntegerSupply">IntegerSupply</a></code> for
the monad being used with <code><a href="/usr/share/doc/libghc-hsp-doc/html/HSP-XMLGenerator.html#t:XMLGenerator">XMLGenerator</a></code>.
</p><p>For example, we can use <code>StateT</code> to provide an <code><a href="HSP-JMacro.html#t:IntegerSupply">IntegerSupply</a></code> instance for <code>ServerPartT</code>:
</p><pre> instance IntegerSupply (ServerPartT (StateT Integer IO)) where
nextInteger = nextInteger'
</pre><p>Alternatively, we can exploit the IO monad to provide an <code><a href="HSP-JMacro.html#t:IntegerSupply">IntegerSupply</a></code> instance for <code>ServerPartT</code>:
</p><pre> instance IntegerSupply (ServerPartT IO) where
nextInteger = fmap (fromIntegral . (`mod` 1024) . hashUnique) (liftIO newUnique)
</pre><p>The <code>ToJExpr XML</code> instance allows you to splice in XML lifted out of an
arbitrary monad to generate DOM nodes with JMacro antiquotation:
</p><pre> js = do html <- unXMLGenT <p>I'm in a Monad!</p>
return [jmacro| document.getElementById("messages").appendChild(`(html)`); |]
</pre><p>The <code>ToJExpr DOMNode</code> instance allows you to run HSP in the Identity
monad to render JMacro in pure code:
</p><pre> html :: DOMNode
html = <p>I'm using <em>JavaScript</em>!</p>
js = [jmacro| var language = `(html)`.getElementsByTagName("em")[0].textContent; |]
</pre><p>You can see here that you get an actual DOM tree in JavaScript. This is
also compatible with libraries such as jQuery and YUI which are able to
wrap DOM nodes in their own type, for example with jQuery:
</p><pre> js = [jmacro| var languages = $(`(html)`).find("em").text(); |]
</pre><p>Or with YUI:
</p><pre> js = [jmacro| var languages = Y.one(`(html)`).one("em").get("text"); |]
</pre><p>There are two ways to turn HTML into a a DOM node in the
browser. One way is to render the HTML to a string, and pass the
string to <code>element.innerHTML</code>. The other way is to us the use the
DOM functions like <code>createElement</code>, <code>setAttribute</code>, to
programatically create the DOM on the client.
</p><p>In webkit-based browsers like Chrome and Safari, the DOM method
appears to be slightly faster. In other browsers, the <code>innerHTML</code>
method appears to be faster. The <code>innerHTML</code> method will almost
always required fewer bytes to be transmitted. Additionally, if
your XML/HTML contains pre-escaped content, you are required to use
<code>innerHTML</code> anyway.
</p><p>So, by default the <code><a href="/usr/share/doc/libghc-jmacro-doc/html/Language-Javascript-JMacro.html#t:ToJExpr">ToJExpr</a></code> <code><a href="/usr/share/doc/libghc-hsp-doc/html/HSP-XML.html#t:XML">XML</a></code> instance uses the <code>innerHTML</code>
method. Though, that could change in the future. If you care about
using one method over the other you can use the <code>newtype</code> wrappers
<code><a href="HSP-JMacro.html#t:XMLToInnerHTML">XMLToInnerHTML</a></code> or <code><a href="HSP-JMacro.html#t:XMLToDOM">XMLToDOM</a></code> to select which method to use.
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">class</span> <a href="#t:IntegerSupply">IntegerSupply</a> m <span class="keyword">where</span><ul class="subs"><li><a href="#v:nextInteger">nextInteger</a> :: m <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Integer">Integer</a></li></ul></li><li class="src short"><a href="#v:nextInteger-39-">nextInteger'</a> :: <a href="/usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Class.html#t:MonadState">MonadState</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Integer">Integer</a> m => m <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Integer">Integer</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:DOMNode">DOMNode</a> = <a href="/usr/share/doc/libghc-hsp-doc/html/HSP-Monad.html#t:HSPT">HSPT</a> <a href="/usr/share/doc/libghc-hsp-doc/html/HSP-XML.html#t:XML">XML</a> Identity <a href="/usr/share/doc/libghc-hsp-doc/html/HSP-XML.html#t:XML">XML</a></li><li class="src short"><span class="keyword">newtype</span> <a href="#t:XMLToInnerHTML">XMLToInnerHTML</a> = <a href="#v:XMLToInnerHTML">XMLToInnerHTML</a> <a href="/usr/share/doc/libghc-hsp-doc/html/HSP-XML.html#t:XML">XML</a></li><li class="src short"><span class="keyword">newtype</span> <a href="#t:XMLToDOM">XMLToDOM</a> = <a href="#v:XMLToDOM">XMLToDOM</a> <a href="/usr/share/doc/libghc-hsp-doc/html/HSP-XML.html#t:XML">XML</a></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:IntegerSupply" class="def">IntegerSupply</a> m <span class="keyword">where</span><a href="src/HSP-JMacro.html#IntegerSupply" class="link">Source</a></p><div class="doc"><p>This class provides a monotonically increasing supply of non-duplicate <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Integer">Integer</a></code> values
</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:nextInteger" class="def">nextInteger</a> :: m <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Integer">Integer</a><a href="src/HSP-JMacro.html#nextInteger" class="link">Source</a></p></div></div><div class="top"><p class="src"><a name="v:nextInteger-39-" class="def">nextInteger'</a> :: <a href="/usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Class.html#t:MonadState">MonadState</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Integer">Integer</a> m => m <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Integer">Integer</a><a href="src/HSP-JMacro.html#nextInteger%27" class="link">Source</a></p><div class="doc"><p>This help function allows you to easily create an <code><a href="HSP-JMacro.html#t:IntegerSupply">IntegerSupply</a></code>
instance for monads that have a <code><a href="/usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Class.html#t:MonadState">MonadState</a></code> <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Integer">Integer</a></code> instance.
</p><p>For example:
</p><pre> instance IntegerSupply (ServerPartT (StateT Integer IO)) where
nextInteger = nextInteger'
</pre></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:DOMNode" class="def">DOMNode</a> = <a href="/usr/share/doc/libghc-hsp-doc/html/HSP-Monad.html#t:HSPT">HSPT</a> <a href="/usr/share/doc/libghc-hsp-doc/html/HSP-XML.html#t:XML">XML</a> Identity <a href="/usr/share/doc/libghc-hsp-doc/html/HSP-XML.html#t:XML">XML</a><a href="src/HSP-JMacro.html#DOMNode" class="link">Source</a></p><div class="doc"><p>Provided for convenience since <code>Ident</code> is exported by both
<code>HSP.Identity</code> and <code>JMacro</code>. Using this you can avoid the need for an
extra and qualified import.
</p></div></div><div class="top"><p class="src"><span class="keyword">newtype</span> <a name="t:XMLToInnerHTML" class="def">XMLToInnerHTML</a> <a href="src/HSP-JMacro.html#XMLToInnerHTML" class="link">Source</a></p><div class="doc"><p>newtype which can be used with <code><a href="/usr/share/doc/libghc-jmacro-doc/html/Language-Javascript-JMacro.html#v:toJExpr">toJExpr</a></code> to specify that the XML
should be converted to a DOM in javascript by using <code>innerHTML</code>
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:XMLToInnerHTML" class="def">XMLToInnerHTML</a> <a href="/usr/share/doc/libghc-hsp-doc/html/HSP-XML.html#t:XML">XML</a></td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:XMLToInnerHTML" class="caption collapser" onclick="toggleSection('i:XMLToInnerHTML')">Instances</p><div id="section.i:XMLToInnerHTML" class="show"><table><tr><td class="src"><a href="/usr/share/doc/libghc-jmacro-doc/html/Language-Javascript-JMacro.html#t:ToJExpr">ToJExpr</a> <a href="HSP-JMacro.html#t:XMLToInnerHTML">XMLToInnerHTML</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">newtype</span> <a name="t:XMLToDOM" class="def">XMLToDOM</a> <a href="src/HSP-JMacro.html#XMLToDOM" class="link">Source</a></p><div class="doc"><p>newtype which can be used with <code><a href="/usr/share/doc/libghc-jmacro-doc/html/Language-Javascript-JMacro.html#v:toJExpr">toJExpr</a></code> to specify that the XML
should be converted to a DOM in javascript by using
<code>createElement</code>, <code>appendChild</code>, and other DOM functions.
</p><p>WARNING: <code>CDATA FALSE</code> values are assumed to be pre-escaped HTML and will be converted to a DOM node by using <code>innerHTML</code>. Additionally, if the call to <code>innerHTML</code> returns more than one node, only the first node is used.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:XMLToDOM" class="def">XMLToDOM</a> <a href="/usr/share/doc/libghc-hsp-doc/html/HSP-XML.html#t:XML">XML</a></td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:XMLToDOM" class="caption collapser" onclick="toggleSection('i:XMLToDOM')">Instances</p><div id="section.i:XMLToDOM" class="show"><table><tr><td class="src"><a href="/usr/share/doc/libghc-jmacro-doc/html/Language-Javascript-JMacro.html#t:ToJExpr">ToJExpr</a> <a href="HSP-JMacro.html#t:XMLToDOM">XMLToDOM</a></td><td class="doc empty"> </td></tr></table></div></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.13.2</p></div></body></html>
|