json-autotype- Automatic type declaration for JSON input data

Safe HaskellNone



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



valueSize :: Value -> Int Source

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 Source

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 Source

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 Source




unDict :: Map Text Type

emptyType :: Type Source

Empty type

extractType :: Value -> Type Source

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

unifyTypes :: Type -> Type -> Type Source

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

typeCheck :: Value -> Type -> Bool Source

Type check the value with the derived type.