[Haskell-cafe] Web application from the ground up

Anton Tayanovskyy anton.tayanovskyy at gmail.com
Thu Oct 9 05:57:36 EDT 2008

Hi Arnaud,

Here's a simple counter program. I mount this to /ws/ with mod_scgi,
and can then do requests http://localhost/ws/ or
http://localhost/ws/?amount=19 (increment by 19 not 1).


I'm no expert but I'm also working on web applications in Haskell now.
If you are like me, not a big fan of monad transformers, the quick and
dirty way to share state between threads is through an MVar as
demonstrated above. Of course CGI is out of question as handles
requests in separate processes. So you would need FastCGI or SCGI or
(I guess that's the best) embedding a web server. Right now I am
playing with my own little pure Haskell SCGI implementation
(http://hpaste.org/11034) which does one forkIO per request, the
interface is:

runSCGI :: Timeout -> PortID -> CGIT IO CGIResult -> IO ()

forkProcess is only helpful to daemonize the program on UNIX.



On Thu, Oct 9, 2008 at 11:25 AM, Arnaud Bailly <abailly at oqube.com> wrote:
> Hello,
> I am trying to implement a complete web application from the ground
> up, with the objective to convince myself and others that 1) it is
> possible, 2) it is powerful and 3) it is more expressive to do such a
> thing in Haskell.
> I managed to get to the point where I can handle users lifecycle
> with DB handling, and I have a CLI application. I have a World that
> stores Session objects, containing a "continuation" of possible
> functions to call.
> The problem I am facing now is how to handle (Fast)CGI requests, given
> that each request seems to be served by a dinstinct invocation of a
> function, and share the World between all connections. I have a vague
> idea that this could be handled by creating some CGIT transformed
> monad operating on a TVar World (that's what is hinted at on haskell
> wiki), but I am not sure how to tackle this.
> I asked this question on #haskell but had to leave too quickly. Some
> people there seems to think this is something very common that has
> been resolved over a hundred times. Once would be enough for me, and I
> would be very happy if someone could point me to the right direction
> or provide some sample code for this.
> Best regards,
> --
> Arnaud Bailly, PhD
> OQube - Software Engineering
> http://www.oqube.com
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list