Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions and types for pretty printing the Json data structures.
Synopsis
- data InlineOption
- = ArrayOnly
- | ObjectOnly
- | Both
- | Neither
- newtype NumSpaces = NumSpaces Natural
- newtype IndentStep = IndentStep Natural
- prettyJson :: InlineOption -> IndentStep -> NumSpaces -> Json -> Json
- simpleEncodePretty :: Applicative f => InlineOption -> IndentStep -> NumSpaces -> Encoder f a -> a -> f Text
- minus :: Natural -> Natural -> Natural
- successor' :: Natural -> Natural
- zero' :: Natural
- _Natural :: AsNatural a => Prism' a Natural
- data Natural
Types
data InlineOption Source #
Some choices for how the Json is indented.
ArrayOnly | Only keep array elements on the same line, input line breaks between object values. |
ObjectOnly | Only keep object elements on the same line, input line breaks between array values. |
Both | Keep both object and array elements on the same line. |
Neither | Input line breaks for both array and object elements. |
Instances
Eq InlineOption Source # | |
Defined in Waargonaut.Prettier (==) :: InlineOption -> InlineOption -> Bool # (/=) :: InlineOption -> InlineOption -> Bool # | |
Show InlineOption Source # | |
Defined in Waargonaut.Prettier showsPrec :: Int -> InlineOption -> ShowS # show :: InlineOption -> String # showList :: [InlineOption] -> ShowS # |
Newtype to indicate how many spaces we would like to use for the indentation
Instances
newtype IndentStep Source #
Newtype for how many spaces the indentation should be increased by for each level.
A safe assumption is for this value to be the same as the number of steps for the identation. Such that an indentation of two spaces will be increased by two for each subsequent level.
Instances
Eq IndentStep Source # | |
Defined in Waargonaut.Prettier (==) :: IndentStep -> IndentStep -> Bool # (/=) :: IndentStep -> IndentStep -> Bool # | |
Show IndentStep Source # | |
Defined in Waargonaut.Prettier showsPrec :: Int -> IndentStep -> ShowS # show :: IndentStep -> String # showList :: [IndentStep] -> ShowS # |
Functions
prettyJson :: InlineOption -> IndentStep -> NumSpaces -> Json -> Json Source #
Apply some indentation and spacing rules to a given Json input.
To apply newlines to object elements only and indent by two spaces, increasing that indentation by two spaces for each nested object or array.
let two = successor' $ successor' zero' prettyJson ArrayOnly (IndentStep two) (NumSpaces two) j
simpleEncodePretty :: Applicative f => InlineOption -> IndentStep -> NumSpaces -> Encoder f a -> a -> f Text Source #
Encode an a
directly to a Text
using
the provided Encoder
, the output will have newlines and
indentation added based on the InlineOption
and NumSpaces
.
let two = successor' $ successor' zero' simpleEncodePretty ArrayOnly (IndentStep two) (NumSpaces two) myEncoder myVal
Rexports
successor' :: Natural -> Natural #