{- | It's important that the content is generated by functions (with dummy arguments) which are also inlined. Otherwise GHC buffers their content and runs into heap exhaustion. -} module Main where import qualified Network.Shed.Httpd as HTTP {-# INLINE items #-} items :: HTTP.Request -> [String] items (HTTP.Request{}) = map show $ iterate ((1::Integer)+) 0 {-# INLINE text #-} text :: HTTP.Request -> String text r = concat $ "" : "" : "" : "" : "" : [] {-# INLINE response #-} response :: HTTP.Request -> HTTP.Response response r = HTTP.Response 200 (("Content-Type", "text/html") : []) (text r) mainText :: IO () mainText = HTTP.initServerLazy 1000 8080 (const (return (HTTP.Response 200 (("Content-Type", "text/plain") : []) (cycle "bla")))) >> return () main :: IO () main = HTTP.initServerLazy 1000 8080 (return . response) >> return ()