json-autotype

Safe HaskellNone
LanguageHaskell2010

Data.Aeson.AutoType.Extract

Description

Extraction and unification of AutoType's Type from Aeson Value.

Synopsis

Documentation

valueSize :: Value -> Int

Compute total number of nodes (and leaves) within the value tree. Each simple JavaScript type (including String) is counted as of size 1, whereas both Array or object types are counted as 1+sum of the sizes of their member values.

valueTypeSize :: Value -> Int

Compute total size of the type of the Value. For: * simple types it is always 1, * for arrays it is just 1+_maximum_ size of the (single) element type, * for objects it is _sum_ of the sizes of fields (since each field type is assumed to be different.)

valueDepth :: Value -> Int

Compute total depth of the value. For: * simple types it is 1 * for either Array or Object, it is 1 + maximum of depths of their members

newtype Dict

Dictionary of types indexed by names.

Constructors

Dict 

Fields

unDict :: Map Text Type
 

Instances

data Type

Union types for JSON values.

Constructors

TNull 
TBool 
TNum 
TString 
TUnion (Set Type) 
TLabel Text 
TObj Dict 
TArray Type 

Instances

Eq Type 
Data Type 
Ord Type 
Show Type 
Generic Type 
Out Type 
Uniplate Type 
type Rep Type 

emptyType :: Type

Empty type

extractType :: Value -> Type

Extract Type from the JSON Value. Unifying types of array elements, if necessary.

unifyTypes :: Type -> Type -> Type

Standard unification procedure on Types, with inclusion of Type unions.

typeCheck :: Value -> Type -> Bool

Type check the value with the derived type.