From a473a346c9990f8a1c9d3c753f05523b52cd8e65 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 20 Aug 2018 10:37:55 -0700 Subject: [PATCH] Slightly different JSON printing options --- src/Language/JSON/Translate.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Language/JSON/Translate.hs b/src/Language/JSON/Translate.hs index 94dc9f770..9bbc6803e 100644 --- a/src/Language/JSON/Translate.hs +++ b/src/Language/JSON/Translate.hs @@ -12,12 +12,6 @@ import Data.Reprinting.Splice import Data.Reprinting.Token import Data.Sequence -newtype JSONBeautyOpts = JSONBeautyOpts { jsonPrettyPrint :: Bool } - deriving (Eq, Show) - -defaultBeautyOpts :: JSONBeautyOpts -defaultBeautyOpts = JSONBeautyOpts True - defaultJSONPipeline :: Monad m => ProcessT m Splice Splice defaultJSONPipeline = translatingJSON @@ -44,6 +38,14 @@ translatingJSON = flattened <~ auto step where step x = pure x +-- | TODO: Fill out and implement configurable options like indentation count, +-- tabs vs. spaces, etc. +data JSONBeautyOpts = JSONBeautyOpts { jsonIndent :: Int, jsonUseTabs :: Bool } + deriving (Eq, Show) + +defaultBeautyOpts :: JSONBeautyOpts +defaultBeautyOpts = JSONBeautyOpts 2 False + beautifyingJSON :: Monad m => JSONBeautyOpts -> ProcessT m Splice Splice beautifyingJSON _ = flattened <~ auto step where step :: Splice -> Seq Splice