Note that there are some explanatory texts on larger screens.

plurals
  1. POHaskell Simple XML generation gives compile error
    text
    copied!<p>I am trying to learn to use the <a href="http://hackage.haskell.org/package/xmlgen-0.4.0.3" rel="nofollow">xmlgen</a> library, but when I tried the example from <a href="http://factisresearch.blogspot.in/2011/05/xmlgen-feature-rich-and-high.html" rel="nofollow">http://factisresearch.blogspot.in/2011/05/xmlgen-feature-rich-and-high.html</a> I get a compile error.</p> <p>Here is the code:</p> <pre><code>import Text.XML.Generator import Data.ByteString.Lazy as BSL import Prelude as P genXml' :: Xml Doc genXml' = let people = [("Stefan", "32"), ("Judith", "4")] in doc defaultDocInfo $ xelem "people" $ xelems $ P.map (\(name, age) -&gt; xelem "person" (xattr "age" age &lt;#&gt; xtext name)) people outputXml :: IO () outputXml = BSL.putStr (xrender genXml') </code></pre> <p>The compiler errors:</p> <pre><code>$ ghc --make prog.hs [1 of 1] Compiling Main ( prog.hs, prog.o ) prog.hs:13:25: No instance for (XmlOutput ByteString) arising from a use of `xrender' Possible fix: add an instance declaration for (XmlOutput ByteString) In the first argument of `BSL.putStr', namely `(xrender genXml')' In the expression: BSL.putStr (xrender genXml') In an equation for `outputXml': outputXml = BSL.putStr (xrender genXml') </code></pre> <p>The compiler seems to be deducing that "xrender genXML'" needs to be of type "XmlOutput ByteString" and there is an instance of this in the xmlgen library. So please help me with understanding what this error means, and how it can be fixed.</p> <p>If it helps, I am using the Haskell Platform in Ubuntu 12.10, ghc 7.4.2 and the xmlgen 0.4.0.3</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload