You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
there is a function called splitOnUnboundedE, which splits conduit by some element of sequence, that this conduit contains.
Is there any way to split not by an element, but using a sequence? I stumbled upon it trying to do something similar to linesUnbounded, but I need so split file using sequence of double newline symbols.
Is it possible now with any existing combinator or if not, would such a function be useful for others to be in combinators library?
In case it is, I tried to modify splitOnUnboundedE, there are some inefficiencies, but is the idea may be useful?
splitOnSeq:: (Monadm, Seq.IsSequenceseq, Eq (Elementseq)) =>seq->ConduitTseqseqm()
splitOnSeq f =
start
where
start = await >>=maybe (return()) (loop id)
loop bldr t =if onull y
thendo
mt <- await
case mt ofNothing->let finalChunk =mconcat$ bldr [t]
in unless (onull finalChunk) $ yield finalChunk
Just t' -> loop (bldr . (t:)) t'
else yield (mconcat$ bldr [x]) >> loop id y
where
(x, y) =let (x : z) =Seq.splitSeq f t in
(x, mconcat$ intersperse f z)
The text was updated successfully, but these errors were encountered:
I don't think it's possible. Generally this is a non-trivial problem to solve. Not impossible or crazy, just that doing this with good performance requires some thinking. I had to do something like that for multipart form data processing in wai-extra IIRC.
Overall, I'd be in favor of some kind of an addition that does this efficiently.
Hi,
there is a function called splitOnUnboundedE, which splits conduit by some element of sequence, that this conduit contains.
Is there any way to split not by an element, but using a sequence? I stumbled upon it trying to do something similar to linesUnbounded, but I need so split file using sequence of double newline symbols.
Is it possible now with any existing combinator or if not, would such a function be useful for others to be in combinators library?
In case it is, I tried to modify splitOnUnboundedE, there are some inefficiencies, but is the idea may be useful?
The text was updated successfully, but these errors were encountered: