<commit_before>{-# LANGUAGE OverloadedStrings #-}
import Data.List (intersperse)
import Data.Map (toList)
import Data.Monoid
import Text.JSON.AttoJSON
import qualified Data.ByteString as S

-- wrap, as in line-wrapping

main :: IO ()
main = mapM_ S.putStrLn . ($[]) . f . either err id . parseJSON =<< S.getContents
  where f (JSArray a)   = t"[" . cat (intersperse (t"\n,") (map (t . showJSON) a)) . t"]"
        f (JSObject o)  = t"{" . cat (intersperse (t"\n,") (map g . toList $ o)) . t"}"
        f _             = error "impossible by decodeStrict post-condition"
        g (key, val)    = t key . t ":" . (t . showJSON) val
        err s           = error $ "JSON decoding: " ++ s
        t x             = (x:)
        cat             = appEndo . mconcat . map Endo
<commit_msg>json-wrap: fix line ending<commit_after>{-# LANGUAGE OverloadedStrings #-}
import Data.List (intersperse)
import Data.Map (toList)
import Data.Monoid
import Text.JSON.AttoJSON
import qualified Data.ByteString as S

-- wrap, as in line-wrapping

main :: IO ()
main = mapM_ S.putStr . ($["\n"]) . f . either err id . parseJSON =<< S.getContents
  where f (JSArray a)   = t"[" . cat (intersperse (t"\n,") (map (t . showJSON) a)) . t"]"
        f (JSObject o)  = t"{" . cat (intersperse (t"\n,") (map g . toList $ o)) . t"}"
        f _             = error "impossible by decodeStrict post-condition"
        g (key, val)    = t key . t ":" . (t . showJSON) val
        err s           = error $ "JSON decoding: " ++ s
        t x             = (x:)
        cat             = appEndo . mconcat . map Endo

{'fraction_non_alphanumeric': 0.15311909262759923, 'fraction_numerical': 0.0, 'mean_word_length': 2.0538461538461537, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2426623', 'n_tokens_mistral': 552, 'n_tokens_neox': 543, 'n_words': 178}