The value module provides a set of type-checking predicates and the identity passthrough function. These predicates return a boolean and accept any value, making them the primary way to branch on value type inside match or cond expressions.
Predicates
value/function?
Returns true when the value is a function.
Result: true when "myFn" resolves to a function in the environment.
value/number?
Returns true when the value is a number.
Result: true
value/string?
Returns true when the value is a string.
Result: true
value/boolean?
Returns true when the value is a boolean.
Result: true
value/object?
Returns true when the value is an object and not null.
Result: true
value/array?
Returns true when the value is an array.
Result: true
value/null?
Returns true when the value is exactly null.
Result: true
Host-only predicates
Two additional predicates are available but are primarily useful when Lion programs work with host values injected through the environment:
value/undefined? — returns true when the value is undefined. JavaScript APIs sometimes return undefined where Lion programs expect null.
value/symbol? — returns true when the value is a JavaScript Symbol, which can appear in host objects or when using module.symbol sentinels.
value/identity
Returns its argument unchanged. This is useful as a no-op branch in match when you want to pass the matched value through without transformation.
Result: 42
Using predicates with match
Predicates are the natural arguments to match branches. Each branch pairs a predicate with a handler lambda:
Use value/identity as the handler when you want a branch to pass the value through unmodified. It is more explicit than an inline ["lambda", ["x"], "x"] and signals intent clearly.