Browse Source

Update WAI to use GHC 7.8

Pinging @kazu-yamamoto
Michael Snoyman 11 years ago
parent
commit
d6dca9dc5d

+ 3 - 0
frameworks/Haskell/wai/bash_profile.sh

@@ -0,0 +1,3 @@
+# Where to find the ghc and cabal executables
+export PATH="/opt/ghc/7.8.3/bin:/opt/cabal/1.20/bin:$PATH"
+export LANG=en_US.UTF-8

+ 3 - 3
frameworks/Haskell/wai/bench/bench.cabal

@@ -11,12 +11,12 @@ executable         bench
 
     extensions: OverloadedStrings
 
-    build-depends: base                          >= 4          && < 5
+    build-depends: base                          >= 4.7        && < 5
                  , aeson                         >= 0.6.1.0
-                 , conduit-extra                 >= 1.1
                  , http-types
                  , network                       >= 2.4
-                 , streaming-commons
                  , text                          >= 1.0
                  , wai                           >= 3.0
                  , warp                          >= 3.0
+                 , blaze-builder
+                 , bytestring                    >= 0.10

+ 12 - 8
frameworks/Haskell/wai/bench/wai.hs

@@ -1,20 +1,24 @@
 {-# LANGUAGE OverloadedStrings, BangPatterns #-}
 
+import Blaze.ByteString.Builder (copyByteString)
 import Control.Concurrent (runInUnboundThread)
 import Data.Aeson ((.=), object, encode)
-import Data.Streaming.Network (bindPortTCP)
+import qualified Data.ByteString.Lazy as L
 import Data.Text (Text)
 import Network.HTTP.Types (status200)
-import Network.Wai (responseLBS)
+import Network.Wai (responseBuilder)
 import qualified Network.Wai.Handler.Warp as W
 
 main :: IO ()
-main = runInUnboundThread $ do
-    s <- bindPortTCP 8000 "*"
-    W.runSettingsSocket settings s app
+main =
+    runInUnboundThread $ W.runSettings settings app
   where
-    settings = W.setOnException (\_ _ -> return ()) W.defaultSettings
+    settings = W.setPort 8000
+             $ W.setOnException (\_ _ -> return ()) W.defaultSettings
     app _ respond = respond response
-    !response = responseLBS status200 ct json
+    !response = responseBuilder status200 ct json
     ct = [("Content-Type", "application/json")]
-    !json = encode $ object ["message" .= ("Hello, World!" :: Text)]
+    !json = copyByteString
+          $ L.toStrict
+          $ encode
+          $ object ["message" .= ("Hello, World!" :: Text)]

+ 1 - 1
frameworks/Haskell/wai/install.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-fw_depends haskell
+fw_depends haskell78

+ 1 - 3
frameworks/Haskell/wai/setup.py

@@ -6,9 +6,7 @@ import os
 
 def start(args, logfile, errfile):
   subprocess.check_call("cabal update", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
-  subprocess.check_call("cabal install --only-dependencies", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
-  subprocess.check_call("cabal configure", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
-  subprocess.check_call("cabal build", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
+  subprocess.check_call("cabal install", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
 
   db_host = args.database_host
   threads = str(args.max_threads)