-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Data structure agnostic JSON serialization
--
-- Most json packages dictate a data structure that corresponds to json
-- values. To serialize other values to json, then that value must be
-- marshalled into the specified structure.
--
-- This library avoids this marshalling step, and is thus potentially
-- more efficient when serializing arbitrary data structures.
-- Unfortunately json-builder cannot yet read or process json data, and
-- it's not clear to me yet how pull a similar kind of trick to avoid
-- unnecessary data structures when parsing json data into arbitrary data
-- types.
@package json-builder
@version 0.0.1
-- | Data structure agnostic JSON serialization
module Data.Json.Builder
-- | The Key typeclass represents types that are rendered into json
-- strings. They are special because only strings can appear as field
-- names of a json objects.
class Value a => Key a
escape :: Key a => a -> Escaped
-- | The Value typeclass represents types that can be rendered into
-- valid json syntax.
class Value a
toBuilder :: Value a => a -> Builder
-- | The Object type represents a builder that constructs syntax for
-- a json object. It has a singleton constructor row, and an
-- instance of monoid, so that arbitrary objects can be constructed. Note
-- that duplicate field names will appear in the output, so it is up to
-- the user of this interface to avoid duplicate field names.
data Object
-- | The row constructs a json object consisting of exactly one
-- field. These objects can be concatinated using mappend.
row :: (Key k, Value a) => k -> a -> Object
-- | The Array type represents a builder that constructs syntax for
-- a json array. It has a singleton constructor element and an
-- instance of monoid, so that arbitrary arrays can be constructed.
data Array
-- | The element function constructs a json array consisting of
-- exactly one value. These arrays can be concatinated using
-- mappend.
element :: Value a => a -> Array
-- | The Escaped type is a special Builder value that represents a
-- UTF-8 encoded string with all necessary characters json-escaped. These
-- builders must not render the opening or closing quotes, which are
-- instead rendered by toBuilder. This is so that Json strings can
-- be efficiently constructed from multiple Haskell strings without
-- actually concatinating the Haskell strings (which might require some
-- kind of conversion in addition to concatination.)
newtype Escaped
Escaped :: Builder -> Escaped
instance [incoherent] Monoid Escaped
instance [incoherent] (Key k, Value a) => Value (HashMap k a)
instance [incoherent] (Key k, Value a) => Value (Map k a)
instance [incoherent] Value a => Value [a]
instance [incoherent] Value [Char]
instance [incoherent] Key [Char]
instance [incoherent] Value Text
instance [incoherent] Key Text
instance [incoherent] Value Text
instance [incoherent] Key Text
instance [incoherent] Value ByteString
instance [incoherent] Key ByteString
instance [incoherent] Value ByteString
instance [incoherent] Key ByteString
instance [incoherent] Value Bool
instance [incoherent] Value Float
instance [incoherent] Value Double
instance [incoherent] Value Word64
instance [incoherent] Value Word32
instance [incoherent] Value Word16
instance [incoherent] Value Word8
instance [incoherent] Value Word
instance [incoherent] Value Integer
instance [incoherent] Value Int64
instance [incoherent] Value Int32
instance [incoherent] Value Int16
instance [incoherent] Value Int8
instance [incoherent] Value Int
instance [incoherent] Value ()
instance [incoherent] Monoid Array
instance [incoherent] Value Array
instance [incoherent] Monoid Object
instance [incoherent] Value Object
instance [incoherent] Value Escaped
instance [incoherent] Key Escaped