Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8894965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:38:50+00:00 2026-06-14T23:38:50+00:00

I am trying to learn to use the xmlgen library, but when I tried

  • 0

I am trying to learn to use the xmlgen library, but when I tried the example from http://factisresearch.blogspot.in/2011/05/xmlgen-feature-rich-and-high.html I get a compile error.

Here is the 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) -> xelem "person" (xattr "age" age <#> xtext name)) people

outputXml :: IO ()
outputXml = BSL.putStr (xrender genXml')

The compiler errors:

$ 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')

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.

If it helps, I am using the Haskell Platform in Ubuntu 12.10, ghc 7.4.2 and the xmlgen 0.4.0.3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:38:51+00:00Added an answer on June 14, 2026 at 11:38 pm

    The compiler seems to be deducing that “xrender genXML'” needs to be of type “XmlOutput ByteString”

    No, the compiler deduces (from the use of BSL.putStr) that xrender genXML' needs to be of type Data.ByteString.Lazy.ByteString.

    Since the type of xrender is

    xrender :: (Renderable r, XmlOutput t) => Xml r -> t
    

    a necessary condition to be able to instantiate t with Data.ByteString.Lazy.ByteString is an XmlOutput instance for lazy ByteStrings.

    Since there is such an instance exported from Text.XML.Generator, the only cause for the error message that I see is that your

    import Data.ByteString.Lazy as BSL
    

    imports the module from a different version of the bytestring package than the xmlgen library was built against.

    Can you check that with ghc-pkg describe xmlgen, which lists the bytestring version it was built against among the dependencies, and ghc-pkg list bytestring to check which bytestring versions you have installed?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn to use awk but it's not behaving how I expect.
I am trying to learn and use html5 and have a basic layout but
I'm trying to learn how to use the Control.Parallel module, but I think I
Im trying to learn how to use JSON from within codeigniter. I'm trying to
I'm trying to learn how to use managed/unmanaged code interop, but I've hit a
I'm trying to learn how to use Magento models, but I'm getting very impatient
I am trying to learn to use Knockoutjs but I am facing a problem
I'm trying to learn iDevice programming and learn to use a new 3rd-party library
I'm trying to learn how to use Python's multiprocessing package, but I don't understand
I'm trying to learn how to use ppl.h in c++ . But I'm not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.