[Haskell-cafe] web musing

2009-06-05 Thread Conor McBride

Comrades

I'm in a perplexing situation and I'd like to appeal to the
sages.

I've never written anything other than static HTML in my life,
and I'd like to make a wee web service: I've heard some
abbreviations, but I don't really know what they mean.

I've got a function (possibly the identity, possibly const ,
who knows?)

  assistant :: String - String

and I want to make a webpage with an edit box and a submit
button. If I press the submit button with the edit box
containing string s, I'd like the page to reload with the
edit box reset to (assistant s).

Will I need to ask systems support to let me install some
haskelly sort of web server? Looks likely, I suppose.

In general, what's an easy way to put a web front end on
functionality implemented in Haskell?

Hoping this isn't a hard question

Conor

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] web musing

2009-06-05 Thread Max Rabkin
On Fri, Jun 5, 2009 at 5:18 PM, Conor McBrideco...@strictlypositive.org wrote:

 Will I need to ask systems support to let me install some
 haskelly sort of web server? Looks likely, I suppose.

 In general, what's an easy way to put a web front end on
 functionality implemented in Haskell?


For something this simple, I'd use CGI. I've never used the Haskell
cgi package, but the basic idea is that the webserver runs an
arbitrary script which reads the HTTP request information from
environment variables, and outputs the response (in the simple case,
just Content-Type: text/html\r\n\r\n++html). The cgi package
probably provides easy access to those environment variables; this is
what Python's cgi module does, for instance.

--Max
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] web musing

2009-06-05 Thread Jason Dagit
On Fri, Jun 5, 2009 at 8:18 AM, Conor McBride co...@strictlypositive.orgwrote:

 Comrades

 I'm in a perplexing situation and I'd like to appeal to the
 sages.

 I've never written anything other than static HTML in my life,
 and I'd like to make a wee web service: I've heard some
 abbreviations, but I don't really know what they mean.

 I've got a function (possibly the identity, possibly const ,
 who knows?)

  assistant :: String - String

 and I want to make a webpage with an edit box and a submit
 button. If I press the submit button with the edit box
 containing string s, I'd like the page to reload with the
 edit box reset to (assistant s).

 Will I need to ask systems support to let me install some
 haskelly sort of web server? Looks likely, I suppose.

 In general, what's an easy way to put a web front end on
 functionality implemented in Haskell?


Several of us cobbled together a web service version of lambdabot at one
point.  We used fast cgi plus apache on the unix side.  In the program we
used the fastcgi haskell bindings (I forget which package), and excuted
lambdabot as a subprocess and communicated over pipes, I think.  Then on the
web page side there was a bit of ajax that executed the cgi request and
spliced the value into the webpage.  It no longer works due to changes in
lambdabot, but all lambdabot knew was that it was running as a normal unix
process.  In a simpler world the code that used the cgi bindings could
directly import your assistant function.

I can try to dig up the sources if you want to see the code.  It was pretty
slick.  And I'd say the bottom line is, you just need (fast) cgi bindings
and you're good on any host where cgi is supported.

Jason
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] web musing

2009-06-05 Thread Justin Bailey
I bet they have PHP on the server already. Write your program so it
takes input from standard in  and writes to standard out. Then just
run your executable from PHP and write to its pipe. Instant web
service!

On Fri, Jun 5, 2009 at 8:18 AM, Conor McBrideco...@strictlypositive.org wrote:
 Comrades

 I'm in a perplexing situation and I'd like to appeal to the
 sages.

 I've never written anything other than static HTML in my life,
 and I'd like to make a wee web service: I've heard some
 abbreviations, but I don't really know what they mean.

 I've got a function (possibly the identity, possibly const ,
 who knows?)

  assistant :: String - String

 and I want to make a webpage with an edit box and a submit
 button. If I press the submit button with the edit box
 containing string s, I'd like the page to reload with the
 edit box reset to (assistant s).

 Will I need to ask systems support to let me install some
 haskelly sort of web server? Looks likely, I suppose.

 In general, what's an easy way to put a web front end on
 functionality implemented in Haskell?

 Hoping this isn't a hard question

 Conor

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] web musing

2009-06-05 Thread Philippa Cowderoy
On Fri, 2009-06-05 at 16:18 +0100, Conor McBride wrote:
 I've got a function (possibly the identity, possibly const ,
 who knows?)
 
assistant :: String - String
 
 and I want to make a webpage with an edit box and a submit
 button. If I press the submit button with the edit box
 containing string s, I'd like the page to reload with the
 edit box reset to (assistant s).
 
 Will I need to ask systems support to let me install some
 haskelly sort of web server? Looks likely, I suppose.
 
 In general, what's an easy way to put a web front end on
 functionality implemented in Haskell?

You don't need a web server so long as you've got a compiler -
Network.CGI ought to work nicely for your purposes, you just have a
binary that's called by the web server, processes the request and yields
input. If you're not doing disk I/O, pretty much the entire program's
plain functional stuff.

-- 
Philippa Cowderoy fli...@flippac.org

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] web musing

2009-06-05 Thread Iavor Diatchki
Hi Conor,
As someone pointed out, CGI is one way to go.
Another option is to write a small Haskell web server. This path is
better if you have an app that needs to keep state, ans uses the
browser mostly as a GUI.

I have just made a package that should make doing this fairly easy.  I
have not uploaded it to hackage yet because I want to make some small
changes still.  You can try out the pre-release from here (the usual
cabal steps should work for making a package/installing)

git clone git://code.galois.com/http-server.git

For an example, take a look in the example directory, there is a
small web-server there, which shows how to all kinds of things,
including ajax interactions with javascript using jQuery.  For
processing form data there is the module:
Network.HTTP.Server.HtmlForm.

Let me know if you have questions, comments, or other feed-back!
-Iavor



On Fri, Jun 5, 2009 at 8:18 AM, Conor McBrideco...@strictlypositive.org wrote:
 Comrades

 I'm in a perplexing situation and I'd like to appeal to the
 sages.

 I've never written anything other than static HTML in my life,
 and I'd like to make a wee web service: I've heard some
 abbreviations, but I don't really know what they mean.

 I've got a function (possibly the identity, possibly const ,
 who knows?)

  assistant :: String - String

 and I want to make a webpage with an edit box and a submit
 button. If I press the submit button with the edit box
 containing string s, I'd like the page to reload with the
 edit box reset to (assistant s).

 Will I need to ask systems support to let me install some
 haskelly sort of web server? Looks likely, I suppose.

 In general, what's an easy way to put a web front end on
 functionality implemented in Haskell?

 Hoping this isn't a hard question

 Conor

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe