Skip to content

Commit 75e164d

Browse files
author
Deian Stefan
committed
update hails to new versions
1 parent 07f5037 commit 75e164d

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

Hails/Database/TCB.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,7 @@ execMongoActionTCB act = do
276276
let pipe = dbActionPipe s
277277
mode = dbActionMode s
278278
db = databaseName . dbActionDB $ s
279-
liftLIO $ ioTCB $ do
280-
res <- Mongo.access pipe mode db act
281-
case res of
282-
Left err -> throwIO $ ExecFailure err
283-
Right v -> return v
279+
liftLIO $ ioTCB $ Mongo.access pipe mode db act
284280

285281

286282
--

Hails/PolicyModule.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ withPolicyModule act = do
431431
List.lookup "HAILS_MONGODB_SERVER" env
432432
mode = maybe master parseMode $
433433
List.lookup "HAILS_MONGODB_MODE" env
434-
pipe <- ioTCB $ Mongo.runIOE $ Mongo.connect (Mongo.host hostName)
434+
pipe <- ioTCB $ Mongo.connect (Mongo.host hostName)
435435
let priv = PrivTCB (toCNF pmOwner)
436436
s0 = makeDBActionStateTCB priv dbName pipe mode
437437
-- Execute policy module entry function with raised clearance:

hails.cabal

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: hails
2-
Version: 0.11.1.2
2+
Version: 0.11.1.3
33
build-type: Simple
44
License: GPL-2
55
License-File: LICENSE
@@ -102,12 +102,13 @@ Library
102102
,bson
103103
,mongoDB
104104
,network
105+
,network-uri
105106
,http-conduit >= 2.1.0
106107
,conduit
107108
,conduit-extra
108109
,resourcet
109110
,exceptions
110-
,wai >= 2.1
111+
,wai >= 2.1 && < 3.0
111112
,wai-app-static
112113
,wai-extra
113114
,http-types
@@ -165,12 +166,13 @@ Executable hails
165166
,bson
166167
,mongoDB
167168
,network
169+
,network-uri
168170
,http-conduit >= 2.1.0
169171
,conduit
170172
,conduit-extra
171173
,resourcet
172174
,exceptions
173-
,wai >= 2.1
175+
,wai >= 2.1 && < 3.0
174176
,wai-extra
175177
,wai-app-static
176178
,warp

hails.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Control.Exception
55
import qualified Data.ByteString.Char8 as S8
66
import qualified Data.ByteString.Lazy.Char8 as L8
77

8+
import Prelude
89
import qualified Data.Text as T
910
import Data.List (isPrefixOf, isSuffixOf)
1011
import qualified Data.List as List
@@ -21,7 +22,6 @@ import Hails.Version
2122
import Network.Wai.Handler.Warp
2223
import Network.Wai.Middleware.RequestLogger
2324

24-
import System.Posix.Env (setEnv)
2525
import System.Environment
2626
import System.Console.GetOpt hiding (Option)
2727
import qualified System.Console.GetOpt as GetOpt
@@ -77,7 +77,7 @@ main = do
7777
cleanOpts opts'
7878
maybe (return ()) (optsToFile opts) $ optOutFile opts
7979
putStrLn $ "Working environment:\n\n" ++ optsToEnvStr opts
80-
forM_ (optsToEnv opts) $ \(k,v) -> setEnv k v True
80+
forM_ (optsToEnv opts) $ \(k,v) -> setEnv k v
8181
let port = fromJust $ optPort opts
8282
hmac_key = L8.pack . fromJust $ optHmacKey opts
8383
persona = personaAuth hmac_key $ T.pack . fromJust . optPersonaAud $ opts
@@ -107,20 +107,24 @@ loadApp :: Bool -- -XSafe ?
107107
-> IO (DC Application)
108108
loadApp safe mpkgDb appName = do
109109
case mpkgDb of
110-
Just pkgDb -> setEnv "GHC_PACKAGE_PATH" pkgDb True
110+
Just pkgDb -> setEnv "GHC_PACKAGE_PATH" pkgDb
111111
Nothing -> return ()
112112
eapp <- runInterpreter $ do
113+
loadModules [appName]
113114
when safe $
114115
set [languageExtensions := [asExtension "Safe"]]
115-
loadModules [appName]
116-
setImports ["Prelude", "LIO", "LIO.DCLabel", "Hails.HttpServer", appName]
116+
setTopLevelModules [appName]
117+
setImports ["Prelude", "LIO", "LIO.DCLabel", "Hails.HttpServer"]
117118
entryFunType <- typeOf "server"
118119
if entryFunType == "DC Application" then
119120
interpret "server" (undefined :: DC Application)
120121
else
121122
interpret "return server" (undefined :: DC Application)
122123
case eapp of
123-
Left err -> throwIO err
124+
Left err -> case err of
125+
WontCompile es -> do putStrLn (unlines $ map errMsg es)
126+
throwIO (userError "Compilation error")
127+
_ -> throwIO err
124128
Right app -> return app
125129

126130
--
@@ -397,7 +401,7 @@ envFromFile file = do
397401
let (key',val') = S8.span (/='=') line
398402
val = safeTail val'
399403
in case S8.words key' of
400-
[key] -> setEnv (S8.unpack key) (S8.unpack val) True
404+
[key] -> setEnv (S8.unpack key) (S8.unpack val)
401405
_ -> do hPutStrLn stderr $ "Invalid environment line: " ++
402406
show (S8.unpack line)
403407
exitFailure

0 commit comments

Comments
 (0)