| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Aeson.AutoType.Extract
Description
Extraction and unification of AutoType's Type from Aeson Value.
- valueSize :: Value -> Int
- valueTypeSize :: Value -> Int
- valueDepth :: Value -> Int
- newtype Dict = Dict {}
- data Type
- emptyType :: Type
- extractType :: Value -> Type
- unifyTypes :: Type -> Type -> Type
- typeCheck :: Value -> Type -> Bool
Documentation
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.
data Type
Union types for JSON values.
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.