Skip to content

Instantly share code, notes, and snippets.

@tcsavage
Created September 3, 2012 16:20
Show Gist options
  • Save tcsavage/3610440 to your computer and use it in GitHub Desktop.
Save tcsavage/3610440 to your computer and use it in GitHub Desktop.
-- | Instantiates the WebCore singleton with a set of configuration parameters.
initialize :: Config -> IO ()
initialize conf
| conf == defaultConfig = awe_webcore_initialize_default
| otherwise = go conf
where
go :: Config -> IO ()
go = do
-- Operating in the (->) monad.
a <- fmap fromBool pluginsEnabled
b <- fmap fromBool javascriptEnabled
c <- fmap fromBool databasesEnabled
d <- fmap mkAweString packagePath
e <- fmap mkAweString localePath
f <- fmap mkAweString userDataPath
g <- fmap mkAweString pluginPath
h <- fmap mkAweString logPath
i <- fmap (CInt . fromIntegral . fromEnum) logLevel
j <- fmap fromBool singleProcess
k <- fmap mkAweString childProcessPath
l <- fmap fromBool autoDetectEncodingEnabled
m <- fmap mkAweString acceptLanguageOverride
n <- fmap mkAweString defaultCharsetOrerride
o <- fmap mkAweString userAgentOverride
p <- fmap mkAweString proxyServer
q <- fmap mkAweString proxyConfigScript
r <- fmap mkAweString authServerWhitelist
s <- fmap fromBool saveCacheAndCookies
t <- fmap (CInt . fromIntegral) maxCacheSize
u <- fmap fromBool sameOriginPolicyEnabled
v <- fmap fromBool winMessagePumpEnabled
w <- fmap mkAweString customCss
return $ do
-- Operating in the IO monad.
d2 <- d
e2 <- e
f2 <- f
g2 <- g
h2 <- h
k2 <- k
m2 <- m
n2 <- n
o2 <- o
p2 <- p
q2 <- q
r2 <- r
w2 <- w
awe_webcore_initialize a b c d2 e2 f2 g2 h2 i j k2 l m2 n2 o2 p2 q2 r2 s t u v w2
mapM_ destroyAweString [d2, e2, f2, g2, h2, k2, m2, n2, o2, p2, q2, r2, w2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment