packages feed

jsonl 0.1.0.0 → 0.2.0.0

raw patch · 2 files changed

+8/−16 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ JSONL: jsonLine :: ToJSON a => a -> Builder

Files

jsonl.cabal view
@@ -1,5 +1,5 @@ name:                jsonl-version:             0.1.0.0+version:             0.2.0.0 synopsis:            JSON Lines description:         Parse and serialize the JSONL format via @aeson@'s ToJSON/FromJSON homepage:            https://github.com/unfoldml/jsonl@@ -12,7 +12,7 @@ build-type:          Simple extra-source-files:  README.md cabal-version:       >=1.10-tested-with:         GHC == 7.10.2+tested-with:         GHC == 9.0.2  library   default-language:    Haskell2010
src/JSONL.hs view
@@ -4,7 +4,9 @@ -- | JSON Lines https://jsonlines.org/ module JSONL (   -- * Encode-  jsonlWriteFile, jsonlToLBS, jsonlBuilder+  jsonlWriteFile, jsonlToLBS+  , jsonlBuilder+  , jsonLine   -- * Decode  , jsonlFromLBS   ) where@@ -36,19 +38,6 @@       in go (eitherDecode' s : acc) srest  --- jsonlFromLBS' :: FromJSON a => LBS.ByteString -> Either String [a]--- jsonlFromLBS' = chop1 (Right mempty)---- chop1 :: FromJSON a =>---          Either String [a] -> LBS.ByteString -> Either String [a]--- chop1 acce lbs = case acce of---   Right acc -> case eitherDecode' s of---     Right x -> chop1 (Right (x : acc)) srest---     Left e -> Left e---   ex -> ex---   where---     (s, srest) = LBS.span (== BS.c2w '\n') lbs- -- | Write a collection of objects to a JSONL-encoded file jsonlWriteFile :: (Foldable t, ToJSON a) => FilePath -> t a -> IO () jsonlWriteFile fpath xs = writeFile fpath (jsonlBuilder xs)@@ -60,6 +49,9 @@ jsonlBuilder :: (Foldable t, ToJSON a) => t a -> BBS.Builder jsonlBuilder = foldMap jsonLine +-- | Render a single JSONL line (together with its newline)+--+-- @since 0.2 jsonLine :: ToJSON a => a -> BBS.Builder jsonLine x = jsonToBuilder x <> BBS.string7 "\n"