@@ -3,6 +3,7 @@ module Network.Wai.Source
3 -- * Conversions
3 -- * Conversions
4 toEnumerator
4 toEnumerator
8import Network.Wai
9import Network.Wai
@@ -35,3 +36,11 @@ toLBS source0 = L.fromChunks `fmap` helper source0 where
35 Just (bs, source') -> do
36 Just (bs, source') -> do
36 rest <- helper source'
37 rest <- helper source'
37 return $ bs : rest
38 return $ bs : rest
40+-- | Convert a lazy bytestring to a 'Source'. This operation does not request lazy I\/O.
41+fromLBS :: L.ByteString -> Source
45+ go [] = Source $ return Nothing
46+ go (x:xs) = Source $ return $ Just (x, go xs)