From 13e2ba29565fdcfc130e2b95d5b763b14b4db1ce Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 17 Aug 2018 16:53:36 -0700 Subject: [PATCH] default JSON pipeline --- src/Language/JSON/Translate.hs | 9 ++++++++- src/Reprinting/Translate.hs | 6 +++--- src/Semantic/Util.hs | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Language/JSON/Translate.hs b/src/Language/JSON/Translate.hs index d4bb8fc60..f08a3fbd1 100644 --- a/src/Language/JSON/Translate.hs +++ b/src/Language/JSON/Translate.hs @@ -15,10 +15,17 @@ data JSONBeautyOpts = JSONBeautyOpts { jsonPrettyPrint :: Bool } defaultBeautyOpts :: JSONBeautyOpts defaultBeautyOpts = JSONBeautyOpts True + +defaultJSONPipeline :: ProcessT (Eff effs) Splice Splice +defaultJSONPipeline + = translatingJSON + ~> beautifyingJSON defaultBeautyOpts + + translatingJSON :: ProcessT (Eff effs) Splice Splice translatingJSON = flattened <~ auto step where step :: Splice -> Seq Splice - step (Insert el@(Truth True) c _) = splice el c "True" + step (Insert el@(Truth True) c _) = splice el c "true" step x = pure x beautifyingJSON :: JSONBeautyOpts -> ProcessT (Eff effs) Splice Splice diff --git a/src/Reprinting/Translate.hs b/src/Reprinting/Translate.hs index 5527bb9fb..24c4c682d 100644 --- a/src/Reprinting/Translate.hs +++ b/src/Reprinting/Translate.hs @@ -52,9 +52,9 @@ translating = flattened <~ autoT (Kleisli step) where translate el c = let emit = pure . splice el c in case (el, c) of (Fragment f, _) -> emit f - (Truth True, _) -> emit "true" - (Truth False, _) -> emit "false" - (Nullity, _) -> emit "null" + (Truth True, _) -> emit "True" + (Truth False, _) -> emit "False" + (Nullity, _) -> emit "Null" (Open, Just List) -> emit "[" (Open, Just Associative) -> emit "{" diff --git a/src/Semantic/Util.hs b/src/Semantic/Util.hs index c34a1ceaf..7716f5eef 100644 --- a/src/Semantic/Util.hs +++ b/src/Semantic/Util.hs @@ -349,6 +349,6 @@ testJSONFile = do testPipeline = do (src, tree) <- testJSONFile - printToTerm $ runReprinter src (translatingJSON ~> beautifyingJSON defaultBeautyOpts) (mark Refactored tree) + printToTerm $ runReprinter src defaultJSONPipeline (mark Refactored tree) printToTerm res = either (putStrLn . show) (BC.putStr . Source.sourceBytes) res