Safe Haskell | None |
---|---|
Language | Haskell98 |
- intoLazyText :: Fold1 Text e Text
- lines :: Transducer Continuous a e Text -> Transducer Delimited a e Text
- lines_ :: Transducer Continuous a e Text -> Transducer Delimited a e Text
- foldedLines :: Transducer Continuous Text e Text
- eachLine :: (Text -> IO (Either e ())) -> Fold1 Text e ()
- decoder :: (forall r. Producer ByteString IO r -> Producer Text IO (Producer ByteString IO r)) -> Transducer Continuous ByteString ByteString Text
- decoderx :: (forall r. Producer ByteString IO r -> Producer Text IO (Producer ByteString IO r)) -> Transducer Continuous ByteString e Text
- utf8 :: Transducer Continuous ByteString ByteString Text
- utf8x :: Transducer Continuous ByteString e Text
Collecting input
intoLazyText :: Fold1 Text e Text Source
Collect strict Text
s into a lazy Text
.
>>>
PT.fold1 intoLazyText (mapM_ yield ["aa","bb","cc"])
("aabbcc",())
Splitting
:: Transducer Continuous a e Text | |
-> Transducer Delimited a e Text |
Split into lines, preserving newlines.
>>>
PT.fold1 (transduce1 (concats . groups (\p -> yield "x" *> p) . lines $ utf8x) intoLazyText) (mapM_ yield ["aa\n","bb"])
("xaa\nxbb\n",())
:: Transducer Continuous a e Text | |
-> Transducer Delimited a e Text |
Split into lines, eliding newlines.
>>>
PT.fold1 (transduce1 (concats . groups (\p -> yield "x" *> p) . lines_ $ utf8x) intoLazyText) (mapM_ yield ["aa\n","bb"])
("xaaxbb",())
Grouping
foldedLines :: Transducer Continuous Text e Text Source
Split the stream into lines, collect them into lazy Text
values, and pass
them downstream.
>>>
PT.fold1 (transduce1 foldedLines (withFold L.list)) (mapM_ yield ["aa","aa\nbb","bb"])
(["aaaa","bbbb"],())
eachLine :: (Text -> IO (Either e ())) -> Fold1 Text e () Source
Split the stream into lines, collect them into lazy Text
values, and
apply an effectul function to each line.
>>>
PT.fold1Fallibly (eachLine $ \l -> pure $ if TL.head l == 'b' then (Left l) else (Right ())) (mapM_ yield ["aa","\nbb"])
Left "bb"
Decoding
:: (forall r. Producer ByteString IO r -> Producer Text IO (Producer ByteString IO r)) | |
-> Transducer Continuous ByteString ByteString Text |
Plug decoding functions from pipes-text
here.
The first undecodable bytes will be the error value.
:: (forall r. Producer ByteString IO r -> Producer Text IO (Producer ByteString IO r)) | |
-> Transducer Continuous ByteString e Text |
Plug decoding functions from pipes-text
here.
BEWARE!
This Transducer
may throw DecodeError
.
BEWARE!
:: Transducer Continuous ByteString ByteString Text |
The first undecodable bytes will be the error value.
>>>
PT.fold1Fallibly (transduce1 utf8 intoLazyText) (mapM_ yield ["aa"])
Right ("aa",())
:: Transducer Continuous ByteString e Text |
>>>
PT.fold1 (transduce1 utf8x intoLazyText) (mapM_ yield ["aa"])
("aa",())
BEWARE!
This Transducer
may throw DecodeError
.
BEWARE!