Z-Data-0.2.0.0: Array, vector and text
Copyright(c) Dong Han 2019
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Z.Data.JSON.Base

Description

This module provides Converter to convert Value to haskell data types, and various tools to help user define FromValue, ToValue and EncodeJSON instance.

Synopsis

Encode & Decode

decode :: FromValue a => Bytes -> (Bytes, Either DecodeError a) Source #

Decode a JSON bytes, return any trailing bytes.

decode' :: FromValue a => Bytes -> Either DecodeError a Source #

Decode a JSON doc, only trailing JSON whitespace are allowed.

decodeText :: FromValue a => Text -> (Text, Either DecodeError a) Source #

Decode a JSON text, return any trailing text.

decodeText' :: FromValue a => Text -> Either DecodeError a Source #

Decode a JSON doc, only trailing JSON whitespace are allowed.

decodeChunks :: (FromValue a, Monad m) => m Bytes -> Bytes -> m (Bytes, Either DecodeError a) Source #

Decode JSON doc chunks, return trailing bytes.

decodeChunks' :: (FromValue a, Monad m) => m Bytes -> Bytes -> m (Either DecodeError a) Source #

Decode JSON doc chunks, consuming trailing JSON whitespaces (other trailing bytes are not allowed).

encode :: EncodeJSON a => a -> Bytes Source #

Directly encode data to JSON bytes.

encodeChunks :: EncodeJSON a => a -> [Bytes] Source #

Encode data to JSON bytes chunks.

encodeText :: EncodeJSON a => a -> Text Source #

Text version encodeBytes.

Re-export Value type

data Value Source #

A JSON value represented as a Haskell value.

The Object's payload is a key-value vector instead of a map, which parsed directly from JSON document. This design choice has following advantages:

  • Allow different strategies handling duplicated keys.
  • Allow different Map type to do further parsing, e.g. FlatMap
  • Roundtrip without touching the original key-value order.
  • Save time if constructing map is not neccessary, e.g. using a linear scan to find a key if only that key is needed.

Instances

Instances details
Eq Value Source # 
Instance details

Defined in Z.Data.JSON.Value

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Show Value Source # 
Instance details

Defined in Z.Data.JSON.Value

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

Generic Value Source # 
Instance details

Defined in Z.Data.JSON.Value

Associated Types

type Rep Value :: Type -> Type #

Methods

from :: Value -> Rep Value x #

to :: Rep Value x -> Value #

Arbitrary Value Source # 
Instance details

Defined in Z.Data.JSON.Value

Methods

arbitrary :: Gen Value #

shrink :: Value -> [Value] #

NFData Value Source # 
Instance details

Defined in Z.Data.JSON.Value

Methods

rnf :: Value -> () #

ShowT Value Source # 
Instance details

Defined in Z.Data.JSON.Value

Methods

toUTF8BuilderP :: Int -> Value -> Builder () Source #

FromValue Value Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON Value Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Value -> Builder () Source #

ToValue Value Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Value -> Value Source #

type Rep Value Source # 
Instance details

Defined in Z.Data.JSON.Value

parse into JSON Value

parseValue :: Bytes -> (Bytes, Either ParseError Value) Source #

Parse Value without consuming trailing bytes.

parseValue' :: Bytes -> Either ParseError Value Source #

Parse Value, and consume all trailing JSON white spaces, if there're bytes left, parsing will fail.

parseValueChunks :: Monad m => m Bytes -> Bytes -> m (Bytes, Either ParseError Value) Source #

Increamental parse Value without consuming trailing bytes.

parseValueChunks' :: Monad m => m Bytes -> Bytes -> m (Either ParseError Value) Source #

Increamental parse Value and consume all trailing JSON white spaces, if there're bytes left, parsing will fail.

Convert Value to Haskell data

convert :: (a -> Converter r) -> a -> Either ConvertError r Source #

Run a Converter with input value.

convert' :: FromValue a => Value -> Either ConvertError a Source #

Run a Converter with input value.

newtype Converter a Source #

Converter for convert result from JSON Value.

This is intended to be named differently from Parser to clear confusions.

Constructors

Converter 

Fields

Instances

Instances details
Monad Converter Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

(>>=) :: Converter a -> (a -> Converter b) -> Converter b #

(>>) :: Converter a -> Converter b -> Converter b #

return :: a -> Converter a #

Functor Converter Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fmap :: (a -> b) -> Converter a -> Converter b #

(<$) :: a -> Converter b -> Converter a #

MonadFail Converter Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fail :: String -> Converter a #

Applicative Converter Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

pure :: a -> Converter a #

(<*>) :: Converter (a -> b) -> Converter a -> Converter b #

liftA2 :: (a -> b -> c) -> Converter a -> Converter b -> Converter c #

(*>) :: Converter a -> Converter b -> Converter b #

(<*) :: Converter a -> Converter b -> Converter a #

Alternative Converter Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

empty :: Converter a #

(<|>) :: Converter a -> Converter a -> Converter a #

some :: Converter a -> Converter [a] #

many :: Converter a -> Converter [a] #

MonadPlus Converter Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

mzero :: Converter a #

mplus :: Converter a -> Converter a -> Converter a #

fail' :: Text -> Converter a Source #

Text version of fail.

(<?>) :: Converter a -> PathElement -> Converter a infixl 9 Source #

Add JSON Path context to a converter

When converting a complex structure, it helps to annotate (sub)converters with context, so that if an error occurs, you can find its location.

withFlatMapR "Person" $ \o ->
  Person
    <$> o .: "name" <?> Key "name"
    <*> o .: "age" <?> Key "age"

(Standard methods like (.:) already do this.)

With such annotations, if an error occurs, you will get a JSON Path location of that error.

prependContext :: Text -> Converter a -> Converter a Source #

Add context to a failure message, indicating the name of the structure being converted.

prependContext "MyType" (fail "[error message]")
-- Error: "converting MyType failed, [error message]"

data PathElement Source #

Elements of a (JSON) Value path used to describe the location of an error.

Constructors

Key !Text

Path element of a key into an object, "object.key".

Index !Int

Path element of an index into an array, "array[index]".

Embedded

path of a embedded (JSON) String

Instances

Instances details
Eq PathElement Source # 
Instance details

Defined in Z.Data.JSON.Base

Ord PathElement Source # 
Instance details

Defined in Z.Data.JSON.Base

Show PathElement Source # 
Instance details

Defined in Z.Data.JSON.Base

Generic PathElement Source # 
Instance details

Defined in Z.Data.JSON.Base

Associated Types

type Rep PathElement :: Type -> Type #

NFData PathElement Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

rnf :: PathElement -> () #

type Rep PathElement Source # 
Instance details

Defined in Z.Data.JSON.Base

type Rep PathElement = D1 ('MetaData "PathElement" "Z.Data.JSON.Base" "Z-Data-0.2.0.0-8QUtxTQS9jpLqloWSyK7oj" 'False) (C1 ('MetaCons "Key" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Text)) :+: (C1 ('MetaCons "Index" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int)) :+: C1 ('MetaCons "Embedded" 'PrefixI 'False) (U1 :: Type -> Type)))

data ConvertError Source #

Instances

Instances details
Eq ConvertError Source # 
Instance details

Defined in Z.Data.JSON.Base

Ord ConvertError Source # 
Instance details

Defined in Z.Data.JSON.Base

Show ConvertError Source # 
Instance details

Defined in Z.Data.JSON.Base

Generic ConvertError Source # 
Instance details

Defined in Z.Data.JSON.Base

Associated Types

type Rep ConvertError :: Type -> Type #

NFData ConvertError Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

rnf :: ConvertError -> () #

ShowT ConvertError Source # 
Instance details

Defined in Z.Data.JSON.Base

type Rep ConvertError Source # 
Instance details

Defined in Z.Data.JSON.Base

type Rep ConvertError = D1 ('MetaData "ConvertError" "Z.Data.JSON.Base" "Z-Data-0.2.0.0-8QUtxTQS9jpLqloWSyK7oj" 'False) (C1 ('MetaCons "ConvertError" 'PrefixI 'True) (S1 ('MetaSel ('Just "errPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [PathElement]) :*: S1 ('MetaSel ('Just "errMsg") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

typeMismatch Source #

Arguments

:: Text

The name of the type you are trying to convert.

-> Text

The JSON value type you expecting to meet.

-> Value

The actual value encountered.

-> Converter a 

Produce an error message like converting XXX failed, expected XXX, encountered XXX.

withScientific :: Text -> (Scientific -> Converter a) -> Value -> Converter a Source #

withScientific name f value applies f to the Scientific number when value is a Number and fails using typeMismatch otherwise.

Warning: If you are converting from a scientific to an unbounded type such as Integer you may want to add a restriction on the size of the exponent (see withBoundedScientific) to prevent malicious input from filling up the memory of the target system.

Error message example

withScientific "MyType" f (String "oops")
-- Error: "converting MyType failed, expected Number, but encountered String"

withBoundedScientific :: Text -> (Scientific -> Converter a) -> Value -> Converter a Source #

withBoundedScientific name f value applies f to the Scientific number when value is a Number with exponent less than or equal to 1024.

withRealFloat :: RealFloat a => Text -> (a -> Converter r) -> Value -> Converter r Source #

@withRealFloat try to convert floating number with following rules:

  • Use ±Infinity to represent out of range numbers.
  • Convert Null as NaN

withBoundedIntegral :: (Bounded a, Integral a) => Text -> (a -> Converter r) -> Value -> Converter r Source #

withBoundedScientific name f value applies f to the Scientific number when value is a Number and value is within minBound ~ maxBound.

withKeyValues :: Text -> (Vector (Text, Value) -> Converter a) -> Value -> Converter a Source #

Directly use Object as key-values for further converting.

withFlatMap :: Text -> (FlatMap Text Value -> Converter a) -> Value -> Converter a Source #

Take a Object as an 'FM.FlatMap T.Text Value', on key duplication prefer first one.

withFlatMapR :: Text -> (FlatMap Text Value -> Converter a) -> Value -> Converter a Source #

Take a Object as an 'FM.FlatMap T.Text Value', on key duplication prefer last one.

withHashMap :: Text -> (HashMap Text Value -> Converter a) -> Value -> Converter a Source #

Take a Object as an 'HM.HashMap T.Text Value', on key duplication prefer first one.

withHashMapR :: Text -> (HashMap Text Value -> Converter a) -> Value -> Converter a Source #

Take a Object as an 'HM.HashMap T.Text Value', on key duplication prefer last one.

withEmbeddedJSON Source #

Arguments

:: Text

data type name

-> (Value -> Converter a)

a inner converter which will get the converted Value.

-> Value 
-> Converter a 

Decode a nested JSON-encoded string.

(.:) :: FromValue a => FlatMap Text Value -> Text -> Converter a Source #

Retrieve the value associated with the given key of an Object. The result is empty if the key is not present or the value cannot be converted to the desired type.

This accessor is appropriate if the key and value must be present in an object for it to be valid. If the key and value are optional, use .:? instead.

(.:?) :: FromValue a => FlatMap Text Value -> Text -> Converter (Maybe a) Source #

Retrieve the value associated with the given key of an Object. The result is Nothing if the key is not present or if its value is Null, or empty if the value cannot be converted to the desired type.

This accessor is most useful if the key and value can be absent from an object without affecting its validity. If the key and value are mandatory, use .: instead.

(.:!) :: FromValue a => FlatMap Text Value -> Text -> Converter (Maybe a) Source #

Retrieve the value associated with the given key of an Object. The result is Nothing if the key is not present or empty if the value cannot be converted to the desired type.

This differs from .:? by attempting to convert Null the same as any other JSON value, instead of interpreting it as Nothing.

convertField Source #

Arguments

:: (Value -> Converter a)

the field converter (value part of a key value pair)

-> FlatMap Text Value 
-> Text 
-> Converter a 

convertFieldMaybe :: (Value -> Converter a) -> FlatMap Text Value -> Text -> Converter (Maybe a) Source #

Variant of .:? with explicit converter function.

convertFieldMaybe' :: (Value -> Converter a) -> FlatMap Text Value -> Text -> Converter (Maybe a) Source #

Variant of .:! with explicit converter function.

FromValue, ToValue & EncodeJSON

data Settings Source #

Generic encode/decode Settings

There should be no control characters in formatted texts since we don't escaping those field names or constructor names (defaultSettings relys on Haskell's lexical property). Otherwise encodeJSON will output illegal JSON string.

Constructors

Settings 

Fields

class ToValue a where Source #

Typeclass for converting to JSON Value.

Minimal complete definition

Nothing

Methods

toValue :: a -> Value Source #

default toValue :: (Generic a, GToValue (Rep a)) => a -> Value Source #

Instances

Instances details
ToValue Bool Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Bool -> Value Source #

ToValue Char Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Char -> Value Source #

ToValue Double Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Double -> Value Source #

ToValue Float Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Float -> Value Source #

ToValue Int Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Int -> Value Source #

ToValue Int8 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Int8 -> Value Source #

ToValue Int16 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Int16 -> Value Source #

ToValue Int32 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Int32 -> Value Source #

ToValue Int64 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Int64 -> Value Source #

ToValue Integer Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue Natural Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue Ordering Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue Word Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Word -> Value Source #

ToValue Word8 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Word8 -> Value Source #

ToValue Word16 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Word16 -> Value Source #

ToValue Word32 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Word32 -> Value Source #

ToValue Word64 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Word64 -> Value Source #

ToValue () Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: () -> Value Source #

ToValue Version Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue ExitCode Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CChar Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CChar -> Value Source #

ToValue CSChar Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CSChar -> Value Source #

ToValue CUChar Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CUChar -> Value Source #

ToValue CShort Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CShort -> Value Source #

ToValue CUShort Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CInt Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CInt -> Value Source #

ToValue CUInt Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CUInt -> Value Source #

ToValue CLong Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CLong -> Value Source #

ToValue CULong Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CULong -> Value Source #

ToValue CLLong Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CLLong -> Value Source #

ToValue CULLong Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CBool Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CBool -> Value Source #

ToValue CFloat Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CFloat -> Value Source #

ToValue CDouble Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CPtrdiff Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CSize Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CSize -> Value Source #

ToValue CWchar Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CWchar -> Value Source #

ToValue CSigAtomic Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CClock Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CClock -> Value Source #

ToValue CTime Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: CTime -> Value Source #

ToValue CUSeconds Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CSUSeconds Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CIntPtr Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CUIntPtr Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CIntMax Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue CUIntMax Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue ByteArray Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue Scientific Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue Text Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Text -> Value Source #

ToValue FlatIntSet Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue Value Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Value -> Value Source #

ToValue HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

ToValue Base64Bytes Source # 
Instance details

Defined in Z.Data.Vector.Base64

ToValue CBytes Source # 
Instance details

Defined in Z.Data.CBytes

Methods

toValue :: CBytes -> Value Source #

ToValue a => ToValue [a] Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: [a] -> Value Source #

ToValue a => ToValue (Maybe a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Maybe a -> Value Source #

(ToValue a, Integral a) => ToValue (Ratio a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Ratio a -> Value Source #

ToValue a => ToValue (Min a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Min a -> Value Source #

ToValue a => ToValue (Max a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Max a -> Value Source #

ToValue a => ToValue (First a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: First a -> Value Source #

ToValue a => ToValue (Last a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Last a -> Value Source #

ToValue a => ToValue (WrappedMonoid a) Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue a => ToValue (Identity a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Identity a -> Value Source #

ToValue a => ToValue (First a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: First a -> Value Source #

ToValue a => ToValue (Last a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Last a -> Value Source #

ToValue a => ToValue (Dual a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Dual a -> Value Source #

ToValue a => ToValue (NonEmpty a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: NonEmpty a -> Value Source #

(Prim a, ToValue a) => ToValue (PrimArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: PrimArray a -> Value Source #

ToValue a => ToValue (SmallArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue a => ToValue (Array a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Array a -> Value Source #

ToValue a => ToValue (HashSet a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: HashSet a -> Value Source #

(Prim a, ToValue a) => ToValue (PrimVector a) Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue a => ToValue (Vector a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Vector a -> Value Source #

ToValue a => ToValue (FlatSet a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: FlatSet a -> Value Source #

ToValue a => ToValue (FlatIntMap a) Source # 
Instance details

Defined in Z.Data.JSON.Base

(ToValue a, ToValue b) => ToValue (Either a b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Either a b -> Value Source #

(ToValue a, ToValue b) => ToValue (a, b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: (a, b) -> Value Source #

HasResolution a => ToValue (Fixed a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Fixed a -> Value Source #

ToValue (Proxy a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Proxy a -> Value Source #

ToValue a => ToValue (HashMap Text a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: HashMap Text a -> Value Source #

(PrimUnlifted a, ToValue a) => ToValue (UnliftedArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

ToValue a => ToValue (FlatMap Text a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: FlatMap Text a -> Value Source #

(ToValue a, ToValue b, ToValue c) => ToValue (a, b, c) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: (a, b, c) -> Value Source #

ToValue a => ToValue (Const a b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Const a b -> Value Source #

ToValue b => ToValue (Tagged a b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Tagged a b -> Value Source #

(ToValue a, ToValue b, ToValue c, ToValue d) => ToValue (a, b, c, d) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: (a, b, c, d) -> Value Source #

(ToValue (f a), ToValue (g a)) => ToValue (Product f g a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Product f g a -> Value Source #

(ToValue (f a), ToValue (g a), ToValue a) => ToValue (Sum f g a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Sum f g a -> Value Source #

(ToValue a, ToValue b, ToValue c, ToValue d, ToValue e) => ToValue (a, b, c, d, e) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: (a, b, c, d, e) -> Value Source #

ToValue (f (g a)) => ToValue (Compose f g a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: Compose f g a -> Value Source #

(ToValue a, ToValue b, ToValue c, ToValue d, ToValue e, ToValue f) => ToValue (a, b, c, d, e, f) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: (a, b, c, d, e, f) -> Value Source #

(ToValue a, ToValue b, ToValue c, ToValue d, ToValue e, ToValue f, ToValue g) => ToValue (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

toValue :: (a, b, c, d, e, f, g) -> Value Source #

class GToValue f where Source #

Methods

gToValue :: Settings -> f a -> Value Source #

Instances

Instances details
GToValue f => GToValue (S1 ('MetaSel ('Nothing :: Maybe Symbol) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gToValue :: forall (a :: k0). Settings -> S1 ('MetaSel 'Nothing u ss ds) f a -> Value Source #

(GToValue f, Selector ('MetaSel ('Just l) u ss ds)) => GToValue (S1 ('MetaSel ('Just l) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gToValue :: forall (a :: k0). Settings -> S1 ('MetaSel ('Just l) u ss ds) f a -> Value Source #

ToValue a => GToValue (K1 i a :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gToValue :: forall (a0 :: k0). Settings -> K1 i a a0 -> Value Source #

GConstrToValue f => GToValue (D1 c f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gToValue :: forall (a :: k0). Settings -> D1 c f a -> Value Source #

class FromValue a where Source #

Minimal complete definition

Nothing

Methods

fromValue :: Value -> Converter a Source #

default fromValue :: (Generic a, GFromValue (Rep a)) => Value -> Converter a Source #

Instances

Instances details
FromValue Bool Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Char Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Double Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Float Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Int Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Int8 Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Int16 Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Int32 Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Int64 Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Integer Source #

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Z.Data.JSON.Base

FromValue Natural Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Ordering Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Word Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Word8 Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Word16 Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Word32 Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Word64 Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue () Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter () Source #

FromValue Version Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue ExitCode Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CChar Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CSChar Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CUChar Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CShort Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CUShort Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CInt Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CUInt Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CLong Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CULong Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CLLong Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CULLong Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CBool Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CFloat Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CDouble Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CPtrdiff Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CSize Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CWchar Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CSigAtomic Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CClock Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CTime Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CUSeconds Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CSUSeconds Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CIntPtr Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CUIntPtr Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CIntMax Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue CUIntMax Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue ByteArray Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Scientific Source #

Note this instance doesn't reject large input

Instance details

Defined in Z.Data.JSON.Base

FromValue Text Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue FlatIntSet Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue Value Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

FromValue Base64Bytes Source # 
Instance details

Defined in Z.Data.Vector.Base64

FromValue CBytes Source #

JSON instances check if CBytes is proper UTF8 encoded, if it is, decode/encode it as Text, otherwise as Bytes.

> encodeText ("hello" :: CBytes)
""hello""
> encodeText ("hello\NUL" :: CBytes)     -- \NUL is encoded as C0 80
"[104,101,108,108,111,192,128]"
Instance details

Defined in Z.Data.CBytes

FromValue a => FromValue [a] Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter [a] Source #

FromValue a => FromValue (Maybe a) Source # 
Instance details

Defined in Z.Data.JSON.Base

(FromValue a, Integral a) => FromValue (Ratio a) Source #

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Ratio and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (Min a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (Min a) Source #

FromValue a => FromValue (Max a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (Max a) Source #

FromValue a => FromValue (First a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (Last a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (WrappedMonoid a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (Identity a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (First a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (Last a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (Dual a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (NonEmpty a) Source # 
Instance details

Defined in Z.Data.JSON.Base

(Prim a, FromValue a) => FromValue (PrimArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (SmallArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (Array a) Source # 
Instance details

Defined in Z.Data.JSON.Base

(Eq a, Hashable a, FromValue a) => FromValue (HashSet a) Source # 
Instance details

Defined in Z.Data.JSON.Base

(Prim a, FromValue a) => FromValue (PrimVector a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (Vector a) Source # 
Instance details

Defined in Z.Data.JSON.Base

(Ord a, FromValue a) => FromValue (FlatSet a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (FlatIntMap a) Source # 
Instance details

Defined in Z.Data.JSON.Base

(FromValue a, FromValue b) => FromValue (Either a b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (Either a b) Source #

(FromValue a, FromValue b) => FromValue (a, b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (a, b) Source #

HasResolution a => FromValue (Fixed a) Source #

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Fixed and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Z.Data.JSON.Base

FromValue (Proxy a) Source #

Use Null as Proxy a

Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (HashMap Text a) Source #

default instance prefer later key

Instance details

Defined in Z.Data.JSON.Base

(PrimUnlifted a, FromValue a) => FromValue (UnliftedArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

FromValue a => FromValue (FlatMap Text a) Source #

default instance prefer later key

Instance details

Defined in Z.Data.JSON.Base

(FromValue a, FromValue b, FromValue c) => FromValue (a, b, c) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (a, b, c) Source #

FromValue a => FromValue (Const a b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (Const a b) Source #

FromValue b => FromValue (Tagged a b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (Tagged a b) Source #

(FromValue a, FromValue b, FromValue c, FromValue d) => FromValue (a, b, c, d) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (a, b, c, d) Source #

(FromValue (f a), FromValue (g a)) => FromValue (Product f g a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (Product f g a) Source #

(FromValue (f a), FromValue (g a), FromValue a) => FromValue (Sum f g a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (Sum f g a) Source #

(FromValue a, FromValue b, FromValue c, FromValue d, FromValue e) => FromValue (a, b, c, d, e) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (a, b, c, d, e) Source #

FromValue (f (g a)) => FromValue (Compose f g a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (Compose f g a) Source #

(FromValue a, FromValue b, FromValue c, FromValue d, FromValue e, FromValue f) => FromValue (a, b, c, d, e, f) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (a, b, c, d, e, f) Source #

(FromValue a, FromValue b, FromValue c, FromValue d, FromValue e, FromValue f, FromValue g) => FromValue (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

fromValue :: Value -> Converter (a, b, c, d, e, f, g) Source #

class GFromValue f where Source #

Methods

gFromValue :: Settings -> Value -> Converter (f a) Source #

Instances

Instances details
(GFromValue f, Selector ('MetaSel ('Just l) u ss ds)) => GFromValue (S1 ('MetaSel ('Just l) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gFromValue :: forall (a :: k0). Settings -> Value -> Converter (S1 ('MetaSel ('Just l) u ss ds) f a) Source #

GFromValue f => GFromValue (S1 ('MetaSel ('Nothing :: Maybe Symbol) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gFromValue :: forall (a :: k0). Settings -> Value -> Converter (S1 ('MetaSel 'Nothing u ss ds) f a) Source #

FromValue a => GFromValue (K1 i a :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gFromValue :: forall (a0 :: k0). Settings -> Value -> Converter (K1 i a a0) Source #

GConstrFromValue f => GFromValue (D1 c f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gFromValue :: forall (a :: k0). Settings -> Value -> Converter (D1 c f a) Source #

class EncodeJSON a where Source #

Minimal complete definition

Nothing

Methods

encodeJSON :: a -> Builder () Source #

default encodeJSON :: (Generic a, GEncodeJSON (Rep a)) => a -> Builder () Source #

Instances

Instances details
EncodeJSON Bool Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Bool -> Builder () Source #

EncodeJSON Char Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Char -> Builder () Source #

EncodeJSON Double Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Double -> Builder () Source #

EncodeJSON Float Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Float -> Builder () Source #

EncodeJSON Int Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Int -> Builder () Source #

EncodeJSON Int8 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Int8 -> Builder () Source #

EncodeJSON Int16 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Int16 -> Builder () Source #

EncodeJSON Int32 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Int32 -> Builder () Source #

EncodeJSON Int64 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Int64 -> Builder () Source #

EncodeJSON Integer Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON Natural Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON Ordering Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON Word Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Word -> Builder () Source #

EncodeJSON Word8 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Word8 -> Builder () Source #

EncodeJSON Word16 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Word16 -> Builder () Source #

EncodeJSON Word32 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Word32 -> Builder () Source #

EncodeJSON Word64 Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Word64 -> Builder () Source #

EncodeJSON () Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: () -> Builder () Source #

EncodeJSON Version Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON ExitCode Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CChar Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CChar -> Builder () Source #

EncodeJSON CSChar Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CSChar -> Builder () Source #

EncodeJSON CUChar Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CUChar -> Builder () Source #

EncodeJSON CShort Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CShort -> Builder () Source #

EncodeJSON CUShort Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CInt Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CInt -> Builder () Source #

EncodeJSON CUInt Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CUInt -> Builder () Source #

EncodeJSON CLong Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CLong -> Builder () Source #

EncodeJSON CULong Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CULong -> Builder () Source #

EncodeJSON CLLong Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CLLong -> Builder () Source #

EncodeJSON CULLong Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CBool Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CBool -> Builder () Source #

EncodeJSON CFloat Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CFloat -> Builder () Source #

EncodeJSON CDouble Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CPtrdiff Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CSize Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CSize -> Builder () Source #

EncodeJSON CWchar Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CWchar -> Builder () Source #

EncodeJSON CSigAtomic Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CClock Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CClock -> Builder () Source #

EncodeJSON CTime Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: CTime -> Builder () Source #

EncodeJSON CUSeconds Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CSUSeconds Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CIntPtr Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CUIntPtr Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CIntMax Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON CUIntMax Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON ByteArray Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON Scientific Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON Text Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Text -> Builder () Source #

EncodeJSON FlatIntSet Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON Value Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Value -> Builder () Source #

EncodeJSON HexBytes Source # 
Instance details

Defined in Z.Data.Vector.Hex

EncodeJSON Base64Bytes Source # 
Instance details

Defined in Z.Data.Vector.Base64

EncodeJSON CBytes Source # 
Instance details

Defined in Z.Data.CBytes

Methods

encodeJSON :: CBytes -> Builder () Source #

EncodeJSON a => EncodeJSON [a] Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: [a] -> Builder () Source #

EncodeJSON a => EncodeJSON (Maybe a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Maybe a -> Builder () Source #

(EncodeJSON a, Integral a) => EncodeJSON (Ratio a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Ratio a -> Builder () Source #

EncodeJSON a => EncodeJSON (Min a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Min a -> Builder () Source #

EncodeJSON a => EncodeJSON (Max a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Max a -> Builder () Source #

EncodeJSON a => EncodeJSON (First a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: First a -> Builder () Source #

EncodeJSON a => EncodeJSON (Last a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Last a -> Builder () Source #

EncodeJSON a => EncodeJSON (WrappedMonoid a) Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON a => EncodeJSON (Identity a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Identity a -> Builder () Source #

EncodeJSON a => EncodeJSON (First a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: First a -> Builder () Source #

EncodeJSON a => EncodeJSON (Last a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Last a -> Builder () Source #

EncodeJSON a => EncodeJSON (Dual a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Dual a -> Builder () Source #

EncodeJSON a => EncodeJSON (NonEmpty a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: NonEmpty a -> Builder () Source #

(Prim a, EncodeJSON a) => EncodeJSON (PrimArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: PrimArray a -> Builder () Source #

EncodeJSON a => EncodeJSON (SmallArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON a => EncodeJSON (Array a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Array a -> Builder () Source #

EncodeJSON a => EncodeJSON (HashSet a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: HashSet a -> Builder () Source #

(Prim a, EncodeJSON a) => EncodeJSON (PrimVector a) Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON a => EncodeJSON (Vector a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Vector a -> Builder () Source #

EncodeJSON a => EncodeJSON (FlatSet a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: FlatSet a -> Builder () Source #

EncodeJSON a => EncodeJSON (FlatIntMap a) Source # 
Instance details

Defined in Z.Data.JSON.Base

(EncodeJSON a, EncodeJSON b) => EncodeJSON (Either a b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Either a b -> Builder () Source #

(EncodeJSON a, EncodeJSON b) => EncodeJSON (a, b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: (a, b) -> Builder () Source #

HasResolution a => EncodeJSON (Fixed a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Fixed a -> Builder () Source #

EncodeJSON (Proxy a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Proxy a -> Builder () Source #

EncodeJSON a => EncodeJSON (HashMap Text a) Source # 
Instance details

Defined in Z.Data.JSON.Base

(PrimUnlifted a, EncodeJSON a) => EncodeJSON (UnliftedArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

EncodeJSON a => EncodeJSON (FlatMap Text a) Source # 
Instance details

Defined in Z.Data.JSON.Base

(EncodeJSON a, EncodeJSON b, EncodeJSON c) => EncodeJSON (a, b, c) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: (a, b, c) -> Builder () Source #

EncodeJSON a => EncodeJSON (Const a b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Const a b -> Builder () Source #

EncodeJSON b => EncodeJSON (Tagged a b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Tagged a b -> Builder () Source #

(EncodeJSON a, EncodeJSON b, EncodeJSON c, EncodeJSON d) => EncodeJSON (a, b, c, d) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: (a, b, c, d) -> Builder () Source #

(EncodeJSON (f a), EncodeJSON (g a)) => EncodeJSON (Product f g a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Product f g a -> Builder () Source #

(EncodeJSON (f a), EncodeJSON (g a), EncodeJSON a) => EncodeJSON (Sum f g a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Sum f g a -> Builder () Source #

(EncodeJSON a, EncodeJSON b, EncodeJSON c, EncodeJSON d, EncodeJSON e) => EncodeJSON (a, b, c, d, e) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: (a, b, c, d, e) -> Builder () Source #

EncodeJSON (f (g a)) => EncodeJSON (Compose f g a) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: Compose f g a -> Builder () Source #

(EncodeJSON a, EncodeJSON b, EncodeJSON c, EncodeJSON d, EncodeJSON e, EncodeJSON f) => EncodeJSON (a, b, c, d, e, f) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: (a, b, c, d, e, f) -> Builder () Source #

(EncodeJSON a, EncodeJSON b, EncodeJSON c, EncodeJSON d, EncodeJSON e, EncodeJSON f, EncodeJSON g) => EncodeJSON (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

encodeJSON :: (a, b, c, d, e, f, g) -> Builder () Source #

class GEncodeJSON f where Source #

Methods

gEncodeJSON :: Settings -> f a -> Builder () Source #

Instances

Instances details
(GEncodeJSON a, GEncodeJSON b) => GEncodeJSON (a :*: b :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gEncodeJSON :: forall (a0 :: k0). Settings -> (a :*: b) a0 -> Builder () Source #

GEncodeJSON f => GEncodeJSON (S1 ('MetaSel ('Nothing :: Maybe Symbol) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gEncodeJSON :: forall (a :: k0). Settings -> S1 ('MetaSel 'Nothing u ss ds) f a -> Builder () Source #

(GEncodeJSON f, Selector ('MetaSel ('Just l) u ss ds)) => GEncodeJSON (S1 ('MetaSel ('Just l) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gEncodeJSON :: forall (a :: k0). Settings -> S1 ('MetaSel ('Just l) u ss ds) f a -> Builder () Source #

EncodeJSON a => GEncodeJSON (K1 i a :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gEncodeJSON :: forall (a0 :: k0). Settings -> K1 i a a0 -> Builder () Source #

GConstrEncodeJSON f => GEncodeJSON (D1 c f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gEncodeJSON :: forall (a :: k0). Settings -> D1 c f a -> Builder () Source #

Helper classes for generics

type family Field f where ... Source #

Equations

Field (a :*: b) = Field a 
Field (S1 (MetaSel Nothing u ss ds) f) = Value 
Field (S1 (MetaSel (Just l) u ss ds) f) = (Text, Value) 

class GWriteFields f where Source #

Methods

gWriteFields :: Settings -> SmallMutableArray s (Field f) -> Int -> f a -> ST s () Source #

Instances

Instances details
(GToValue f, Selector ('MetaSel ('Just l) u ss ds)) => GWriteFields (S1 ('MetaSel ('Just l) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gWriteFields :: forall s (a :: k0). Settings -> SmallMutableArray s (Field (S1 ('MetaSel ('Just l) u ss ds) f)) -> Int -> S1 ('MetaSel ('Just l) u ss ds) f a -> ST s () Source #

GToValue f => GWriteFields (S1 ('MetaSel ('Nothing :: Maybe Symbol) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gWriteFields :: forall s (a :: k0). Settings -> SmallMutableArray s (Field (S1 ('MetaSel 'Nothing u ss ds) f)) -> Int -> S1 ('MetaSel 'Nothing u ss ds) f a -> ST s () Source #

(ProductSize a, GWriteFields a, GWriteFields b, Field a ~ Field b) => GWriteFields (a :*: b :: Type -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gWriteFields :: forall s (a0 :: k). Settings -> SmallMutableArray s (Field (a :*: b)) -> Int -> (a :*: b) a0 -> ST s () Source #

class GMergeFields f where Source #

Instances

Instances details
GMergeFields (S1 ('MetaSel ('Just l) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gMergeFields :: Proxy# (S1 ('MetaSel ('Just l) u ss ds) f) -> SmallMutableArray s (Field (S1 ('MetaSel ('Just l) u ss ds) f)) -> ST s Value Source #

GMergeFields (S1 ('MetaSel ('Nothing :: Maybe Symbol) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gMergeFields :: Proxy# (S1 ('MetaSel 'Nothing u ss ds) f) -> SmallMutableArray s (Field (S1 ('MetaSel 'Nothing u ss ds) f)) -> ST s Value Source #

GMergeFields a => GMergeFields (a :*: b :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gMergeFields :: Proxy# (a :*: b) -> SmallMutableArray s (Field (a :*: b)) -> ST s Value Source #

class GConstrToValue f where Source #

Methods

gConstrToValue :: Bool -> Settings -> f a -> Value Source #

Instances

Instances details
GConstrToValue (V1 :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrToValue :: forall (a :: k0). Bool -> Settings -> V1 a -> Value Source #

(Constructor c, GToValue (S1 sc f)) => GConstrToValue (C1 c (S1 sc f) :: k -> Type) Source #

Constructor with a single payload

Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrToValue :: forall (a :: k0). Bool -> Settings -> C1 c (S1 sc f) a -> Value Source #

Constructor c => GConstrToValue (C1 c (U1 :: k -> Type) :: k -> Type) Source #

Constructor without payload, convert to String

Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrToValue :: forall (a :: k0). Bool -> Settings -> C1 c U1 a -> Value Source #

(GConstrToValue f, GConstrToValue g) => GConstrToValue (f :+: g :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrToValue :: forall (a :: k0). Bool -> Settings -> (f :+: g) a -> Value Source #

(ProductSize (a :*: b), GWriteFields (a :*: b), GMergeFields (a :*: b), Constructor c) => GConstrToValue (C1 c (a :*: b) :: Type -> Type) Source #

Constructor with multiple payloads

Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrToValue :: forall (a0 :: k). Bool -> Settings -> C1 c (a :*: b) a0 -> Value Source #

type family LookupTable f where ... Source #

Equations

LookupTable (a :*: b) = LookupTable a 
LookupTable (S1 (MetaSel Nothing u ss ds) f) = Vector Value 
LookupTable (S1 (MetaSel (Just l) u ss ds) f) = FlatMap Text Value 

class GFromFields f where Source #

Methods

gFromFields :: Settings -> LookupTable f -> Int -> Converter (f a) Source #

Instances

Instances details
(GFromValue f, Selector ('MetaSel ('Just l) u ss ds)) => GFromFields (S1 ('MetaSel ('Just l) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gFromFields :: forall (a :: k0). Settings -> LookupTable (S1 ('MetaSel ('Just l) u ss ds) f) -> Int -> Converter (S1 ('MetaSel ('Just l) u ss ds) f a) Source #

GFromValue f => GFromFields (S1 ('MetaSel ('Nothing :: Maybe Symbol) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gFromFields :: forall (a :: k0). Settings -> LookupTable (S1 ('MetaSel 'Nothing u ss ds) f) -> Int -> Converter (S1 ('MetaSel 'Nothing u ss ds) f a) Source #

(ProductSize a, GFromFields a, GFromFields b, LookupTable a ~ LookupTable b) => GFromFields (a :*: b :: Type -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gFromFields :: forall (a0 :: k). Settings -> LookupTable (a :*: b) -> Int -> Converter ((a :*: b) a0) Source #

class GBuildLookup f where Source #

Instances

Instances details
GBuildLookup (S1 ('MetaSel ('Just l) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gBuildLookup :: Proxy# (S1 ('MetaSel ('Just l) u ss ds) f) -> Int -> Text -> Value -> Converter (LookupTable (S1 ('MetaSel ('Just l) u ss ds) f)) Source #

GBuildLookup (S1 ('MetaSel ('Nothing :: Maybe Symbol) u ss ds) f :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gBuildLookup :: Proxy# (S1 ('MetaSel 'Nothing u ss ds) f) -> Int -> Text -> Value -> Converter (LookupTable (S1 ('MetaSel 'Nothing u ss ds) f)) Source #

(GBuildLookup a, GBuildLookup b) => GBuildLookup (a :*: b :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gBuildLookup :: Proxy# (a :*: b) -> Int -> Text -> Value -> Converter (LookupTable (a :*: b)) Source #

class GConstrFromValue f where Source #

Instances

Instances details
GConstrFromValue (V1 :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrFromValue :: forall (a :: k0). Bool -> Settings -> Value -> Converter (V1 a) Source #

(Constructor c, GFromValue (S1 sc f)) => GConstrFromValue (C1 c (S1 sc f) :: k -> Type) Source #

Constructor with a single payload

Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrFromValue :: forall (a :: k0). Bool -> Settings -> Value -> Converter (C1 c (S1 sc f) a) Source #

Constructor c => GConstrFromValue (C1 c (U1 :: k -> Type) :: k -> Type) Source #

Constructor without payload, convert to String

Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrFromValue :: forall (a :: k0). Bool -> Settings -> Value -> Converter (C1 c U1 a) Source #

(GConstrFromValue f, GConstrFromValue g) => GConstrFromValue (f :+: g :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrFromValue :: forall (a :: k0). Bool -> Settings -> Value -> Converter ((f :+: g) a) Source #

(ProductSize (a :*: b), GFromFields (a :*: b), GBuildLookup (a :*: b), Constructor c) => GConstrFromValue (C1 c (a :*: b) :: Type -> Type) Source #

Constructor with multiple payloads

Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrFromValue :: forall (a0 :: k). Bool -> Settings -> Value -> Converter (C1 c (a :*: b) a0) Source #

class GAddPunctuation (f :: * -> *) where Source #

Methods

gAddPunctuation :: Proxy# f -> Builder () -> Builder () Source #

Instances

Instances details
GAddPunctuation a => GAddPunctuation (a :*: b) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gAddPunctuation :: Proxy# (a :*: b) -> Builder () -> Builder () Source #

GAddPunctuation (S1 ('MetaSel ('Nothing :: Maybe Symbol) u ss ds) f) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gAddPunctuation :: Proxy# (S1 ('MetaSel 'Nothing u ss ds) f) -> Builder () -> Builder () Source #

GAddPunctuation (S1 ('MetaSel ('Just l) u ss ds) f) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gAddPunctuation :: Proxy# (S1 ('MetaSel ('Just l) u ss ds) f) -> Builder () -> Builder () Source #

class GConstrEncodeJSON f where Source #

Methods

gConstrEncodeJSON :: Bool -> Settings -> f a -> Builder () Source #

Instances

Instances details
GConstrEncodeJSON (V1 :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrEncodeJSON :: forall (a :: k0). Bool -> Settings -> V1 a -> Builder () Source #

(Constructor c, GEncodeJSON (S1 ('MetaSel ('Just l) u ss ds) f)) => GConstrEncodeJSON (C1 c (S1 ('MetaSel ('Just l) u ss ds) f) :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrEncodeJSON :: forall (a :: k0). Bool -> Settings -> C1 c (S1 ('MetaSel ('Just l) u ss ds) f) a -> Builder () Source #

(Constructor c, GEncodeJSON (S1 ('MetaSel ('Nothing :: Maybe Symbol) u ss ds) f)) => GConstrEncodeJSON (C1 c (S1 ('MetaSel ('Nothing :: Maybe Symbol) u ss ds) f) :: k -> Type) Source #

Constructor with a single payload

Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrEncodeJSON :: forall (a :: k0). Bool -> Settings -> C1 c (S1 ('MetaSel 'Nothing u ss ds) f) a -> Builder () Source #

Constructor c => GConstrEncodeJSON (C1 c (U1 :: k -> Type) :: k -> Type) Source #

Constructor without payload, convert to String

Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrEncodeJSON :: forall (a :: k0). Bool -> Settings -> C1 c U1 a -> Builder () Source #

(GConstrEncodeJSON f, GConstrEncodeJSON g) => GConstrEncodeJSON (f :+: g :: k -> Type) Source # 
Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrEncodeJSON :: forall (a :: k0). Bool -> Settings -> (f :+: g) a -> Builder () Source #

(GEncodeJSON (a :*: b), GAddPunctuation (a :*: b), Constructor c) => GConstrEncodeJSON (C1 c (a :*: b) :: Type -> Type) Source #

Constructor with multiple payloads

Instance details

Defined in Z.Data.JSON.Base

Methods

gConstrEncodeJSON :: forall (a0 :: k). Bool -> Settings -> C1 c (a :*: b) a0 -> Builder () Source #

Helper for manually writing encoders

kv :: Text -> Builder () -> Builder () Source #

Use : as separator to connect a label(no need to escape, only add quotes) with field builders.

kv' :: Text -> Builder () -> Builder () Source #

Use : as separator to connect a label(escaped and add quotes) with field builders.

string :: Text -> Builder () Source #

Escape text into JSON string and add double quotes, escaping rules:

   '\b':  "\b"
   '\f':  "\f"
   '\n':  "\n"
   '\r':  "\r"
   '\t':  "\t"
   '"':  "\""
   '\':  "\\"
   '/':  "\/"
   other chars <= 0x1F: "\u00XX"

commaSepList :: EncodeJSON a => [a] -> Builder () Source #

Use , as separator to connect list of builders.

commaSepVec :: (EncodeJSON a, Vec v a) => v a -> Builder () Source #

Use , as separator to connect a vector of builders.