Skip to main content
Version: 0.4.11

Types

MistQL has 8 core datatypes, many of which correspond to their JSON counterparts.

External types are types that can be either provided or returned by a MistQL query. All other types are considered internal and cannot be provided to or returned from MistQL.

TypePrimitiveExternalComment
stringโœ”โœ”Series of unicode codepoints
numberโœ”โœ”Doubles, without NaN or infinity
booleanโœ”โœ”
nullโœ”โœ”
objectโœ”Stringly typed keys
arrayโœ”Can be nonhomogenous
functionArity not part of type system
regex

Type Equality#

Equality in MistQL is strict, meaning that if two variables have different data types, they are considered unequal.

TypeEquality
stringexact
numberIEEE 754 compliant
booleanexact
nulltrue
objectDeep equality
arrayDeep equality
functionReferential
regexOn source and flag

Casting Tables#

MistQL defines casting from some types to other types

TypeCast to FloatCast To StringTruthiness
stringParsed as float, as per JSON standard.noopfalse if empty, true otherwise
numbernoopAs base 10 float. If number is an integer, no trailing digits or decimal. Exponential notation when not within non-inclusive range 1e-7 to 1e21IEEE 754 compliant
boolean1 for true, 0 for false"true" for true, "false" for falseStandard
null0"null"false
objectInvalid OperationConcise JSON, recursively converting itemsfalse if empty, true otherwise
arrayInvalid OperationConcise JSON, recursively converting itemsfalse if empty, true otherwise
functionInvalid OperationInvalid Operationtrue
regexInvalid OperationInvalid Operationtrue

Type Properties#

There are 3 properties that any given type may or may not exhibit. The properties are as follows:

  • Comparable: Whether or not a type can be compared to another of the same type.
  • NumberCastable: Whether or not a type can be cast to the number type.
  • StringCastable: Whether or not a type can be cast to the string type.

The table for which types exhibit which properties can be seen below:

TypeComparableNumberCastableStringCastable
stringโœ”โœ”โœ”
numberโœ”โœ”โœ”
booleanโœ”โœ”โœ”
nullโœ”โœ”โœ”
objectโœ”
arrayโœ”
function
regex