I'd have to see a complete repro to know why the program in question doesn't stream. But I _can_ explain how best to do something like this.
To frame this: why is something like ResourceT needed here? The issue is we want to ensure exception safety around the open file handle, and guarantee that the handle is closed regardless of any exceptions being thrown. ResourceT solves this problem by letting you register cleanup actions. This allows for solving some really complicated dynamic allocation problems, but for most cases it's overkill. Instead, a simple use of the bracket pattern is sufficient. You can do that with `withSourceFile`:
```
#!/usr/bin/env stack
-- stack --resolver lts-11.10 script
import Network.Wai
import Network.Wai.Handler.Warp
import Network.Wai.Conduit
import Network.HTTP.Types
import Conduit
import Data.ByteString.Builder (byteString)
main :: IO ()
main = run 3000 app
app :: Application
app _req respond =
withSourceFile "Main.hs" $ \src ->
respond $ responseSource status200 []
$ src .| mapC (Chunk . byteString)
```
You can also do this by sticking with ResourceT, which requires jumping through some hoops with monad transformers to ensure the original ResourceT context is used. I don't recommend this approach unless you really need it: it's complicated, and slightly slower than the above. But in case you're curious:
```
#!/usr/bin/env stack
-- stack --resolver lts-11.10 script
import Network.Wai
import Network.Wai.Handler.Warp
import Network.Wai.Conduit
import Network.HTTP.Types
import Conduit
import Data.ByteString.Builder (byteString)
import Control.Monad.Trans.Resource
main :: IO ()
main = run 3000 app
app :: Application
app _req respond =
runResourceT $ withInternalState $ \is ->
respond $ responseSource status200 [] $
transPipe (`runInternalState` is) (sourceFile "Main.hs") .|
mapC (Chunk . byteString)
```