Created
June 25, 2016 00:38
-
-
Save LeifW/33e1ba6b95c9e7452a591f301e20292e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE OverloadedStrings #-} | |
| import Network.Wai | |
| import Network.HTTP.Types | |
| import Network.Wai.Handler.Warp (run) | |
| -- | |
| import Control.Concurrent (threadDelay) | |
| import Data.Atomics.Counter --(newCounter, incrCounter) | |
| app :: AtomicCounter -> Application | |
| app counter _ respond = do | |
| --putStrLn "I've done some IO here" | |
| print =<< incrCounter 1 counter | |
| threadDelay 1000000 | |
| incrCounter (-1) counter | |
| respond $ responseLBS | |
| status200 | |
| [("Content-Type", "text/plain")] | |
| "Hello, Web!" | |
| main :: IO () | |
| main = do | |
| counter <- newCounter 0 | |
| putStrLn $ "http://localhost:8080/" | |
| run 8080 (app counter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment