haskell-wai

What forces drove WAI Application to be redesigned five times?

落花浮王杯 提交于 2019-12-10 02:15:59
问题 I took a curious look at WAI interface and while it looks simple, I was surprised to see how many iterations it took to stabilize at the current form! I had assumed that CPS style for resource safety would be the most interesting thing but it looks like there is much more to learn from! $ git log -p --reverse -- wai/Network/Wai.hs | grep '\+type Application' +type Application = Request -> Iteratee B.ByteString IO Response +type Application = Request -> ResourceT IO Response +type Application

Where to add 'always running' thread to Yesod applications

江枫思渺然 提交于 2019-12-08 00:31:27
问题 I'm writing a Yesod application, but it also needs to fork several non-web services. (UDP listeners, TCP listening port, etc.) Where is the correct place to splice in a fork, such that this work seamlessly, regardless of whether my app is running in 'yesod devel' or deployed for production. P.S. I really just want to add a pseudo-Main, which will be forked (at service start) by whichever webserver runs the app through WAI. 回答1: You should put it in the makeApplication function in the

Where to add 'always running' thread to Yesod applications

非 Y 不嫁゛ 提交于 2019-12-06 09:16:23
I'm writing a Yesod application, but it also needs to fork several non-web services. (UDP listeners, TCP listening port, etc.) Where is the correct place to splice in a fork, such that this work seamlessly, regardless of whether my app is running in 'yesod devel' or deployed for production. P.S. I really just want to add a pseudo-Main, which will be forked (at service start) by whichever webserver runs the app through WAI. You should put it in the makeApplication function in the scaffolded Application.hs file. This function will run once for every instance of your web application that is

How do I use wai-handler-devel with a simple wai application

放肆的年华 提交于 2019-12-06 03:22:10
问题 I have the basic "hello world" application setup using wai, and would like to use wai-handler-devel, but am unsure how to go about it and can't find any examples of it in usage on a wai project. {-# LANGUAGE OverloadedStrings #-} import Network.Wai import Network.HTTP.Types import Network.Wai.Handler.Warp (run) import Data.ByteString.Lazy.Char8 () -- Just for an orphan instance app :: Application app _ = return $ responseLBS status200 [("Content-Type", "text/plain")] "Hello, World!" main ::

What forces drove WAI Application to be redesigned five times?

折月煮酒 提交于 2019-12-05 01:33:46
I took a curious look at WAI interface and while it looks simple, I was surprised to see how many iterations it took to stabilize at the current form! I had assumed that CPS style for resource safety would be the most interesting thing but it looks like there is much more to learn from! $ git log -p --reverse -- wai/Network/Wai.hs | grep '\+type Application' +type Application = Request -> Iteratee B.ByteString IO Response +type Application = Request -> ResourceT IO Response +type Application = Request -> C.ResourceT IO Response +type Application = Request -> IO Response +type Application =

How do I use wai-handler-devel with a simple wai application

不羁的心 提交于 2019-12-04 07:42:03
I have the basic "hello world" application setup using wai, and would like to use wai-handler-devel, but am unsure how to go about it and can't find any examples of it in usage on a wai project. {-# LANGUAGE OverloadedStrings #-} import Network.Wai import Network.HTTP.Types import Network.Wai.Handler.Warp (run) import Data.ByteString.Lazy.Char8 () -- Just for an orphan instance app :: Application app _ = return $ responseLBS status200 [("Content-Type", "text/plain")] "Hello, World!" main :: IO () main = do putStrLn $ "http://localhost:8080/" run 8080 app What do I need to do to get wai-handler

Scotty: connection pool as monad reader

微笑、不失礼 提交于 2019-11-28 18:48:45
There are trillions of monad tutorial including the reader and it seems all clear when you read about it. But when you actually need to write, it becomes a different matter. I'v never used the Reader, just never got to it in practice. So I don't know how to go about it although I read about it. I need to implement a simple database connection pool in Scotty so every action can use the pool. The pool must be "global" and accessible by all action functions. I read that the way to do it is the Reader monad. If there are any other ways please let me know. Can you please help me and show how to do

Scotty: connection pool as monad reader

孤人 提交于 2019-11-27 11:40:34
问题 There are trillions of monad tutorial including the reader and it seems all clear when you read about it. But when you actually need to write, it becomes a different matter. I'v never used the Reader, just never got to it in practice. So I don't know how to go about it although I read about it. I need to implement a simple database connection pool in Scotty so every action can use the pool. The pool must be "global" and accessible by all action functions. I read that the way to do it is the