Show HN: Haquery – jQuery for Haskell
github.com
github.com
Maybe "jQuery for Haskell" is not too descriptive: it is a pure Haskell html dom manipulation tool, mainly useful for templating and/or scraping.
It uses the same selectors and API as jQuery, the only deviations are due to immutability (eg. if you modify a selection, the original graph will not be updated of course, so you have to use "alter" or something similar).
Edit:
Feel free to send a pull request or suggest any changes. The time I poured into the library was mainly focused on getting even the most complex nested selectors to work, because I felt that is the lion's share of the work.
I've been playing around with making a DSL vs. using string based selectors, and I've had little success coming up with something sensible. Have you thought about this at all?
Regarding the selector DSLs, I also went with the string solution, however I translate all selectors to a recursive ADT which could be used directly.
Maybe we should unite our powers ;)
R.E. uniting forces, yeah! I looked through your code a bit, and it looks like we have the same underlying idea (yours seems a bit less convoluted than mine, though :-). I'm not really actively using hquery for anything more than a static site generator I wrote with it, but I wouldn't mind spending a few more hours/week on haskell code.
I was really surprised that there are no more templating languages for Haskell given the availability of the mighty parsec.
I am following you on github, stay in touch.
Queries could easily be modelled with the list monad. Add the stateT transformer for effects. Add lenses for niceness. (Lenses could really beautify the internal implementation as well me thinks).
I'd love to hear about some of your design choices making this.
However, the only defense I can come up with (not that I really want to excuse myself) is this is part of an effort (Hakit) to make Haskell web development accessible to HS beginners. I was a beginner myself when I started Hakit, a web toolkit, and I was overwhelmed by the seemingly complex Haskell APIs. So I tried to build a complete toolkit while forcing the users learning as few Haskell concepts as possible, without writing exceedingly ugly code.
I will surely try to make this more appealing to Haskell ninjas too though.
However, that being said, I look forward to seeing how this progresses and anything else you may have in store.
My reaction to monads & transformers was: "I never asked for this."
I got used to them in a couple of weeks but I know multiple people personally who couldn't grasp them in months. I try to provide them with a toolkit to flex their muscles on and be productive with.
For parsing HTML, I wrote a library called HandsomeSoup. It adds CSS selectors to HXT, which provides everything you need for parsing HTML: https://github.com/egonschiele/HandsomeSoup
Likewise, for serious Haskell webdev, Snap, or perhaps HappStack or Yesod, are the tools to consider for general Haskell backed web engineering