title: How to write a simple HTTP server in Haskell using Network.HTTP.receiveHTTP
body: <p>The module <a href="http://hackage.haskell.org/packages/archive/HTTP/4000.1.1/doc/html/Network-HTTP.html" rel="noreferrer"><code>Network.HTTP</code></a>
  exposes the functions <code>receiveHTTP</code> and <code>respondHTTP</code> which I'd like to use for a very basic web server. I wrote a stub that just waits for clients:</p>
  
  <pre><code>{-# LANGUAGE OverloadedStrings #-}
  module Main where
  
  import Network.HTTP
  import Network
  import Control.Monad
  
  main = withSocketsDo $ do
    socket &lt;- listenOn $ PortNumber 8080
    forever $ do
      (handle, host, port) &lt;- accept socket
      print (host, port)
  </code></pre>
  
  <p>Here <code>accpet</code> gives me a <code>Handle</code>, and now I can't figure out how to use a <code>Handle</code> with <code>receiveHTTP</code>.</p>
  
  <p>I found <a href="http://lstephen.wordpress.com/2008/02/14/a-simple-haskell-web-server/" rel="noreferrer">an example</a> with Google, but it is from 2008 and does not work anymore. And I was not able to port it.</p>
  
  <p>Any ideas?</p>