@@ -8,16 +8,15 @@ module Language.JSON.PrettyPrint
88
99import Prologue
1010
11- import Control.Effect
12- import Control.Effect.Error
13- import Control.Monad.Trans (lift )
14- import Streaming
11+ import Control.Effect
12+ import Control.Effect.Error
13+ import Streaming
1514import qualified Streaming.Prelude as Streaming
1615
1716import Data.Reprinting.Errors
17+ import Data.Reprinting.Scope
1818import Data.Reprinting.Splice
1919import Data.Reprinting.Token
20- import Data.Reprinting.Scope
2120
2221-- | Default printing pipeline for JSON.
2322defaultJSONPipeline :: (Member (Error TranslationError ) sig , Carrier sig m )
@@ -35,9 +34,9 @@ printingJSON = Streaming.map step where
3534 step s@ (Defer el cs) =
3635 let ins = New el cs
3736 in case (el, listToMaybe cs) of
38- (Truth True , _) -> ins " true"
39- (Truth False , _) -> ins " false"
40- (Nullity , _) -> ins " null"
37+ (Truth True , _) -> ins " true"
38+ (Truth False , _) -> ins " false"
39+ (Nullity , _) -> ins " null"
4140
4241 (Open , Just List ) -> ins " ["
4342 (Close , Just List ) -> ins " ]"
@@ -48,7 +47,7 @@ printingJSON = Streaming.map step where
4847 (Sep , Just Pair ) -> ins " :"
4948 (Sep , Just Hash ) -> ins " ,"
5049
51- _ -> s
50+ _ -> s
5251 step x = x
5352
5453-- TODO: Fill out and implement configurable options like indentation count,
@@ -65,22 +64,22 @@ beautifyingJSON :: (Member (Error TranslationError) sig, Carrier sig m)
6564 -> Stream (Of Fragment ) m a
6665 -> Stream (Of Splice ) m a
6766beautifyingJSON _ s = Streaming. for s step where
68- step (Defer el cs) = lift (throwError (NoTranslation el cs))
67+ step (Defer el cs) = effect (throwError (NoTranslation el cs))
6968 step (Verbatim txt) = emit txt
7069 step (New el cs txt) = case (el, cs) of
7170 (Open , Hash : _) -> emit txt *> layout HardWrap *> indent 2 (hashDepth cs)
7271 (Close , Hash : rest) -> layout HardWrap *> indent 2 (hashDepth rest) *> emit txt
7372 (Sep , List : _) -> emit txt *> space
7473 (Sep , Pair : _) -> emit txt *> space
7574 (Sep , Hash : _) -> emit txt *> layout HardWrap *> indent 2 (hashDepth cs)
76- _ -> emit txt
75+ _ -> emit txt
7776
7877-- | Produce whitespace minimal JSON.
7978minimizingJSON :: (Member (Error TranslationError ) sig , Carrier sig m )
8079 => Stream (Of Fragment ) m a
8180 -> Stream (Of Splice ) m a
8281minimizingJSON s = Streaming. for s step where
83- step (Defer el cs) = lift (throwError (NoTranslation el cs))
82+ step (Defer el cs) = effect (throwError (NoTranslation el cs))
8483 step (Verbatim txt) = emit txt
8584 step (New _ _ txt) = emit txt
8685
0 commit comments