I have this code:
import Pipes
import Pipes.Safe
import qualified Pipes.Prelude as P
import qualified Pipes.Safe.Prelude as P
import System.IO
import Data.Text as T
import Data.Text.IO as TIO
import qualified Pipes.Prelude.Text as T
someFunc :: IO ()
someFunc = runSafeT $
P.withFile file1 ReadMode $ \file1Handle -> do
file2 <- liftIO $ TIO.hGetLine file1Handle
runEffect $
for (P.zip (T.fromHandleLn file1Handle)
(T.readFileLn $ T.unpack file2))
(\(l1,l2) -> do yield l2
yield l1)
>-> T.stdoutLn
But it seems quite hacky, and I would like to be able to open the second file from within the pipe, from what I read in the first line of the first file. Any idea?