Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Streaming interface for JSONL-encoded files, based on conduit
The JSONL (JSON Lines) format : https://jsonlines.org/
Synopsis
- jsonToLBSC :: (ToJSON a, Monad m) => ConduitT a o m ByteString
- sinkFileC :: (ToJSON a, MonadResource m) => FilePath -> ConduitT a o m ()
- appendFileC :: (ToJSON a, MonadResource m) => FilePath -> ConduitT a o m ()
- jsonFromLBSC :: (FromJSON a, Monad m) => ByteString -> ConduitT Void a m ()
- jsonFromLBSCE :: (FromJSON a, Monad m) => ByteString -> ConduitT i (Either String a) m ()
- sourceFileC :: (MonadResource m, FromJSON a) => FilePath -> ConduitT () a m ()
- sourceFileCE :: (MonadResource m, FromJSON a) => FilePath -> ConduitT () (Either String a) m ()
- sourceFileC_ :: MonadResource m => FilePath -> ConduitT () ByteString m ()
Encode
jsonToLBSC :: (ToJSON a, Monad m) => ConduitT a o m ByteString Source #
Render a stream of JSON-encodable objects into a ByteString
I/O
:: (ToJSON a, MonadResource m) | |
=> FilePath | path of JSONL file to be created |
-> ConduitT a o m () |
Render a stream of JSON-encodable objects into a JSONL file
appendFileC :: (ToJSON a, MonadResource m) => FilePath -> ConduitT a o m () Source #
Like sinkFileC
but in AppendMode
, which means that the handle is positioned at the
end of the file.
Since: 0.1.1
Decode
jsonFromLBSC :: (FromJSON a, Monad m) => ByteString -> ConduitT Void a m () Source #
Source a ByteString
for JSONL records
NB in case of a decoding error the stream is stopped
jsonFromLBSCE :: (FromJSON a, Monad m) => ByteString -> ConduitT i (Either String a) m () Source #
Like jsonFromLBSC
but all decoding errors are passed in Left values
I/O
:: (MonadResource m, FromJSON a) | |
=> FilePath | path of JSONL file to be read |
-> ConduitT () a m () |
Read a JSONL file and stream the decoded records
NB : ignores any parsing errors and returns
:: (MonadResource m, FromJSON a) | |
=> FilePath | path of JSONL file to be read |
-> ConduitT () (Either String a) m () |
Read a JSONL file and stream the decoded records
NB : decoding error messages are in Left
values
Tokenize only
:: MonadResource m | |
=> FilePath | path of JSONL file to be read |
-> ConduitT () ByteString m () |
The outgoing stream elements are the lines of the file, i.e guaranteed not to contain newline characters
NB : In case it wasn't clear, no JSON parsing is done, only string copies