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 7410479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:14:25+00:00 2026-05-29T06:14:25+00:00

I ve been using hxt with no problem, but there was a problem since

  • 0

I ve been using hxt with no problem, but there was a problem since the beginning.
See, imagine the following piece of code

liftKeys = atTag "myKeys" >>>
   proc e -> do
      key1 <- getAttrValue "name"   -< e
      key2 <- getAttrValue "chance" -< e
      returnA -< (key1, key2)

I have used it like that trough many documents to parse, and im before the classic programmig problem, lack of abstraction.

<zone id= "greenhill">
  <key name="a" chance = "10" />
  <key name="v"  chance = "10"/>
</zone>

I have four (and more coming) files to parse like this example. Some have 2 attributes, others have 5 , someothers 1 etc
I cant be writing different versions of liftKeys according the amount of attributes my file has. The thing is i dont really understand arrows or what im doing u.u
There has to be some fold or something to write more simple code.

Do you know a better use of this?

  • 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-05-29T06:14:25+00:00Added an answer on May 29, 2026 at 6:14 am

    If you have a differing number of attributes, then it seems like the most natural solution to construct an arrow from a list of attribute names. However, to do that, we are going to need a small helper function to turn a list of arrows into a single arrow that produces a list.

    arrowList :: Arrow a => [a b c] -> a b [c]
    arrowList []         = arr $ const []
    arrowList (a:arrows) = proc b -> do
        c  <- a -< b
        cs <- arrowList arrows -< b
        returnA -< (c:cs)
    

    Probably something like this already exists in some arrow utility library, but I wasn’t able to find one with a quick search. Here, given a list of arrows [a b c], we merge them into a single arrow by first feeding b to the first arrow and then recursively merging the rest of the list and feeding b to that merged arrow.

    I wrote the above function using the arrow notation to make it easier to explain, but you could implement it simply like this:

    arrowList :: Arrow a => [a b c] -> a b [c]
    arrowList []         = arr $ const []
    arrowList (a:arrows) = a &&& arrowList arrows >>> arr (uncurry (:))
    

    Now we can implement the liftKeys function like this

    liftKeys :: ArrowXml a => [String] -> a XmlTree [String]
    liftKeys keys = atTag "myKeys" >>> arrowList (map getAttrValue keys)
    

    And your original example above could be expressed as liftKeys ["name", "chance"].

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

Sidebar

Related Questions

I been using VS2008 Pro for a long time now but since of licensing
Ive been using the following code to convert aac / mp3 files into pcm.
I've been using a method for serving downloads but since it was not secure
Been using PHP/MySQL for a little while now, and I'm wondering if there are
Ive been using jquery to do this, but now I need to do it
I've been using Eclipse since 2.x and IDEs in general for over 20 years
I have been using Indy to transfers files via FTP for years now but
Been using a Copy method with this code in it in various places in
Ive been using the following to change the width of the div.my-div that appears
Been using the code below to return a single record from the database. I

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.