Skip to content

Instantly share code, notes, and snippets.

@amothic
Created July 5, 2013 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amothic/5937576 to your computer and use it in GitHub Desktop.
Save amothic/5937576 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
import Network.Wai
import Network.HTTP.Types (status200)
import Network.Wai.Handler.Warp (run)
import Control.Monad.Trans (liftIO, lift)
import Data.IORef (newIORef, atomicModifyIORef)
import Data.ByteString.Lazy.UTF8 (fromString)
application counter request = do
count <- lift $ incCount counter
return $ responseLBS status200 [("Content-type", "text/html")] $ fromString $ show count
incCount counter = atomicModifyIORef counter (\c -> (c+1, c))
main = do
counter <- newIORef 0
run 3000 $ application counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment