View all results

Basic types

FQL has seven built-in value types:

Type Example Description
NONE NONE Represents an absent or undefined value.
bool true, false Represents a truth value.
number 42, 3.14 Represents numeric values, both integer and floating-point.
string "hello" Represents text.
array [1, 2, 3] Represents an ordered sequence of values.
object { name: "Ada" } Represents a set of named fields.
binary module-specific Represents raw bytes.

Ferret hosts may also define additional value types — documents, elements, HTTP responses, files, handles, database connections, and other external resources. These are called host values and are covered separately in Host Values.

NONE

NONE is Ferret’s equivalent of null, nil, or None in other languages.

It represents the absence of a value.

example.fql Ferret v2
query.fql
FQL
RETURN NONE

NONE is a real value in FQL. It can be assigned to variables, placed inside arrays and objects, returned from functions, and compared with other values.

example.fql Ferret v2
query.fql
FQL
LET value = NONE RETURN { value: value, isMissing: value == NONE }

Unlike SQL NULL, comparing with NONE does not automatically produce another NONE.

example.fql Ferret v2
query.fql
FQL
RETURN { same: NONE == NONE, different: NONE != 1 }

NONE is useful when a value is intentionally absent:

example.fql Ferret v2
query.fql
FQL
LET user = { name: "Ada", email: NONE } RETURN user.email

It is useful when that absence needs to remain distinct from ordinary values such as false, 0, "", [], or {}.

Booleans

Boolean values represent truth values.

FQL has two boolean values:

  • true
  • false

Booleans are commonly produced by comparison operators, logical operators, predicates, and conditions.

example.fql Ferret v2
query.fql
FQL
LET count = 3 RETURN { hasItems: count > 0, isEmpty: count == 0 }

Boolean values can be combined with logical operators:

example.fql Ferret v2
query.fql
FQL
LET enabled = true LET hasAccess = false RETURN enabled AND hasAccess

Numbers

FQL uses the number type for numeric values. Numbers can be written as integers or decimals:

example.fql Ferret v2
query.fql
FQL
RETURN { count: 10, price: 19.95, temperature: -4.5 }

Numbers support arithmetic operations:

example.fql Ferret v2
query.fql
FQL
LET price = 20 LET tax = 1.5 RETURN price + tax

They can also be compared:

example.fql Ferret v2
query.fql
FQL
RETURN { less: 1 < 2, equal: 10 == 10, greater: 5 > 3 }

Numbers are ordered by numeric value:

  • 1 < 2
  • 10 > 2
  • -1 < 0

Numeric-looking strings are still strings. FQL does not treat "10" as the same value as 10.

example.fql Ferret v2
query.fql
FQL
RETURN { number: 10, string: "10", same: 10 == "10" }

Use explicit conversion functions when a script needs to turn text into a number or a number into text.

Strings

Strings represent text and can be written as quoted literals:

example.fql Ferret v2
query.fql
FQL
RETURN "Hello, Ferret"

Strings can be empty:

example.fql Ferret v2
query.fql
FQL
RETURN ""

An empty string is still a text value, not the absence of a value. It is different from NONE.

example.fql Ferret v2
query.fql
FQL
RETURN { empty: "", missing: NONE, same: "" == NONE }

Strings are commonly used for names, labels, URLs, selectors, extracted text, keys, and identifiers.

example.fql Ferret v2
query.fql
FQL
RETURN { title: "Example page", url: "https://example.com", selector: ".article-title" }

Strings can be compared with other strings. Comparisons use the string contents, so two strings are equal when they contain the same sequence of characters.

example.fql Ferret v2
query.fql
FQL
RETURN { same: "ferret" == "ferret", different: "ferret" != "Ferret" }

String comparisons are always case-sensitive.

example.fql Ferret v2
query.fql
FQL
RETURN "Ferret" == "ferret"

Arrays

Arrays are ordered collections of values written with square brackets:

example.fql Ferret v2
query.fql
FQL
RETURN [1, 2, 3]

Arrays can contain any FQL value:

example.fql Ferret v2
query.fql
FQL
RETURN [ NONE, true, 42, "text", [1, 2], { name: "Ada" } ]

Arrays preserve the order of their elements.

example.fql Ferret v2
query.fql
FQL
RETURN ["first", "second", "third"]

Array items can be accessed by index using bracket notation:

example.fql Ferret v2
query.fql
FQL
LET roles = ["admin", "editor", "viewer"] RETURN roles[0]

An empty array represents a collection with no items:

example.fql Ferret v2
query.fql
FQL
RETURN []

An empty array is not the same as NONE.

example.fql Ferret v2
query.fql
FQL
RETURN { emptyArray: [], missing: NONE, same: [] == NONE }

Arrays are commonly produced by FOR loops and collection operations.

example.fql Ferret v2
query.fql
FQL
LET numbers = ( FOR value IN [1, 2, 3] RETURN value * 2 ) RETURN numbers

Array elements can be nested:

example.fql Ferret v2
query.fql
FQL
RETURN [ ["Ada", "Lovelace"], ["Grace", "Hopper"] ]

Objects

An object is an unordered collection of named values, written with curly braces:

example.fql Ferret v2
query.fql
FQL
RETURN { name: "Ada", active: true }

Each object entry has a property name and a value, which can be any FQL value.

example.fql Ferret v2
query.fql
FQL
RETURN { name: "Ada", age: 36, email: NONE, tags: ["math", "computing"], profile: { active: true } }

Object properties can be accessed with dot notation or bracket notation.

Use dot notation when the property name is known ahead of time:

example.fql Ferret v2
query.fql
FQL
LET user = { name: "Ada", active: true } RETURN user.name

Use bracket notation when the property name comes from a string literal or variable:

example.fql Ferret v2
query.fql
FQL
LET user = { name: "Ada", active: true } LET property = "name" RETURN user[property]

Because objects do not preserve key order, property order does not affect object equality. Two objects with the same properties and values are equal, even if those properties were written in a different order.

example.fql Ferret v2
query.fql
FQL
RETURN { a: 1, b: 2 } == { b: 2, a: 1 }

An empty object represents a record with no properties:

example.fql Ferret v2
query.fql
FQL
RETURN {}

An empty object is not the same as NONE.

example.fql Ferret v2
query.fql
FQL
RETURN { emptyObject: {}, missing: NONE, same: {} == NONE }

Binary values

Binary values represent raw bytes.

They are used for data that should be handled as bytes instead of ordinary text, such as downloaded files, encoded payloads, images, archives, or data exchanged with runtime modules.

Binary values are part of the FQL value model, but they are usually returned by functions, modules, or runtime operations. For example, an HTTP, file, or encoding module may return binary data when the result should be treated as bytes.

example.fql Ferret v2
query.fql
FQL
LET file = IO::NET::HTTP::GET("https://avatars.githubusercontent.com/u/39228646?s=200&v=4") RETURN file
Ferret’s default serializer encodes binary values as Base64 strings, so byte-oriented data can be represented safely in text-based output formats.

Type checks

Scripts often receive values in different shapes. Use type-related functions or predicates when logic needs to branch based on the kind of value being handled.

example.fql Ferret v2
query.fql
FQL
LET value = "42" RETURN IS_STRING(value) ? "text" : "not text"

Type checks are useful when working with external data, optional fields, runtime-backed values, or module results.

example.fql Ferret v2
query.fql
FQL
LET user = { name: "Ada", } LET value = user.email RETURN value == NONE ? "missing" : value

See the Standard Library section for the full list of available type-checking functions.

Where to go next