Last active
August 29, 2015 14:02
-
-
Save mwotton/ef339396a7a9cb34287d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
streamFiles :: IO () -> [FilePath] -> Source IO (Flush Builder) | |
streamFiles ready filepaths = do | |
--liftIO $ ready | |
yield $ Chunk $ fromLazyByteString "{" | |
mapM_ (\x -> do | |
DCC.sourceFile x $= transducer | |
yield $ Chunk $ fromLazyByteString ",\n") | |
filepaths | |
yield $ Chunk $ fromLazyByteString "}" | |
transducer :: ConduitM Text (Flush Builder) m1 a0 | |
transducer = undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/Net/Tribe.hs:264:13: | |
No instance for (MonadResource IO) | |
arising from a use of ‘DCC.sourceFile’ | |
In the first argument of ‘($=)’, namely ‘DCC.sourceFile x’ | |
In a stmt of a 'do' block: DCC.sourceFile x $= transducer | |
In the expression: | |
do { DCC.sourceFile x $= transducer; | |
yield $ Chunk $ fromLazyByteString "," } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Test where | |
import Blaze.ByteString.Builder (Builder) | |
import Blaze.ByteString.Builder (fromLazyByteString) | |
import Conduit (Flush) | |
import Conduit (Source) | |
import Conduit (Flush (..)) | |
import Conduit (yield) | |
import Conduit (($=)) | |
import Conduit (ConduitM) | |
import qualified Conduit as DCC | |
import Data.Text (Text) | |
import Filesystem.Path.CurrentOS (FilePath) | |
import Prelude hiding (FilePath) | |
streamFiles :: IO () -> [FilePath] -> Source IO (Flush Builder) | |
streamFiles ready filepaths = do | |
--liftIO $ ready | |
yield $ Chunk $ fromLazyByteString "{" | |
mapM_ (\x -> do | |
DCC.sourceFile x $= transducer | |
yield $ Chunk $ fromLazyByteString ",\n") | |
filepaths | |
yield $ Chunk $ fromLazyByteString "}" | |
transducer :: ConduitM Text (Flush Builder) m1 a0 | |
transducer = undefined |
{-# LANGUAGE OverloadedStrings #-}
module Test where
import Blaze.ByteString.Builder (Builder)
import Blaze.ByteString.Builder (fromLazyByteString)
import Data.Conduit (Flush)
import Data.Conduit (Source)
import Data.Conduit (Flush (..))
import Data.Conduit (yield)
import Data.Conduit (($=))
import Data.Conduit (ConduitM)
import qualified Data.Conduit.Binary as DCC
import Data.ByteString (ByteString)
import Control.Monad.Trans.Resource
streamFiles :: MonadResource m => IO () -> [FilePath] -> Source m (Flush Builder)
streamFiles ready filepaths = do
--liftIO $ ready
yield $ Chunk $ fromLazyByteString "{"
mapM_ (\x -> do
_ <- DCC.sourceFile x $= transducer
yield $ Chunk $ fromLazyByteString ",\n")
filepaths
yield $ Chunk $ fromLazyByteString "}"
transducer :: ConduitM ByteString (Flush Builder) m1 a0
transducer = undefined
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does what i want, but not relying on lazy bytestrings is half the reason to use conduit in the first place.