[web-devel] Some Fun: Panther AJAX Library

Greg Weber greg at gregweber.info
Sat Jun 25 16:01:18 CEST 2011

very neat!

It would be nice to work at a higher level- involve it with the
html generation so that the code isn't so tied to the Dom.

On Fri, Jun 24, 2011 at 4:17 PM, Blake Rain <blake.rain at gmail.com> wrote:

> Dear All,
> Some history: About two or so  years ago, before I'd heard of Yesod, we
> started  a  web  development  framework  for Haskell  which  we  called
> Panther.  This  framework was  quite similar to  ASP.Net or  PHP: pages
> were source  files and it  had a pre-processor which  generated Haskell
> code.
> To cut  a long story short: I  never really finished off  Panther, as I
> found out  about Michael's wonderful  Yesod.  I'm now  resurrecting the
> project with  a different goal: hosting multiple  WAI applications over
> clusters.  The  fun  part of  the  old  Panther  was  that it  used  an
> evolutionary  rewiring   algorithm  to  distribute   applications  over
> clusters of computers over multiple sites. As you can imagine, that was
> a great joy to write :)
> When the newer Panther actually stabilizes (or even works) I'll explain
> various bits of it in more detail.
> One of  the nice features that  Panther had was the  ability to specify
> client-side operations on the server. For example, given the HTML:
> >  <div id="myDiv">
> >    <i>Some Text</i>
> >  </div>
> >  <input type="text" id="name" />
> >  <button type="button" panther:onclick="changeMyDiv">
> >    Change!
> >  </button>
> We could  replace the text in  the <div> with "Other  Text", change the
> style of the <div> and print the contents of the input element with the
> following Haskell code:
> >  changeMyDiv :: (Monad m) => Element -> Ajax m ()
> >  changeMyDiv button = do
> >    [div, input] <- getElementsById ["myDiv", "name"]
> >
> >    setInnerHtml div "Other Text"
> >    setStyle div ["font-weight" =: "bold", "color" =: "green"]
> >
> >    v <- getValue input
> >    liftIO $ print v
> (the  code was  actually a  little more  complex,  as 'getElementsById'
> yielded a list of 'Maybe Element'. But you get the idea).
> In earlier days  - before we adopted Yesod and  rewrote everything :) -
> we found this  functionality to be quite useful.  We  mostly used it to
> handle dynamic forms, progress reporting and so on.
> I'd completely forgotten about  the panther-ajax package.  The past few
> discussions on  web-devel regarding dynamic  forms made me  think about
> how we  have solved  similar problems, and  what we  used to do  in the
> past.
> Anyway, last week I decided to  port the package over to Yesod and make
> some  improvements to  the API.   I've put  an experimental  version on
> GitHub for those who are at all interested in this:
> https://github.com/MassiveTactical/panther-ajax
> There is a simple example in the  repo. For those of you who don't want
> to build the example, but would  still like see it working, the example
> is currently running at:
> http://meadowstalk.com:3141/
> It should still be running...
> You can get an immediate idea for how it works by examining the network
> activity in Chrome (or whatever your browser may be).
> If any of you are interested -  or are idly curious and have some spare
> time - I'd love to hear any  feedback. The library still needs a lot of
> improvement. There is  still quite a bit of code to  port over, and the
> optimizing assembler  needs some  tender loving care  before it  can be
> used again.
> Kind Regards,
> Blake Rain
> Massive Tactical
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20110625/b33588d7/attachment.htm>

More information about the web-devel mailing list