Answer to the updated question:
That's not going to work very well because of how Conduits are set up. Notice that the incoming type for a conduit is fixed to receive a single value:
MonadResource m => C.Conduit i m o
If you want to take multiple inputs, you have to request them as a pair
MonadResource m => C.Conduit (i1, i2) m o
But to give that conduit its input, you've already written your existing solution!
On the other hand, if there was a way to make Conduits into Arrows, you could do this without much difficulty with the (***)
function that does exactly what you want -- namely, take two input arrows and combine them to produce an arrow that acts on the pair. My understanding is that there isn't a good way to turn Conduits into Arrows. However, if you downgrade readFileConduit
to readFile
(working with a Handle
and hGetContents
) you can compose extractTimeStamp
and readFile
inside the IO monad.
do let timestamp = extractTimeStamp <..args..>
contents <- readFile <..args..>
return (timestamp, contents)
You can then lift that function into a conduit with a simple lift
.