(a: unknown): a is {
[x: string]: unknown
[x: number]: unknown
[x: symbol]: unknown
}Matches non-null objects other than arrays.
When to use
Use to match broad non-null, non-array object values.
Details
This predicate uses Predicate.isObject: it returns true for values whose
runtime type is "object", are not null, and are not arrays. It can match
Date, RegExp, and class instances; use instanceOf or a more specific
pattern when those cases need to be distinguished.
Example (Matching record objects)
import { Match } from "effect"
const analyzeValue = Match.type<unknown>().pipe(
Match.when(Match.record, (obj) => {
const keys = Object.keys(obj)
const valueCount = keys.length
return `Object with ${valueCount} properties: [${keys.join(", ")}]`
}),
Match.when(
Match.instanceOf(Array),
(arr) => `Array with ${arr.length} items`
),
Match.orElse(() => "Not an object")
)
console.log(analyzeValue({ name: "Alice", age: 30 })) // "Object with 2 properties: [name, age]"
console.log(analyzeValue([1, 2, 3])) // "Array with 3 items"
console.log(analyzeValue(null)) // "Not an object"
console.log(analyzeValue("hello")) // "Not an object"export const const record: Predicate.Refinement<
unknown,
{ [x: PropertyKey]: unknown }
>
Matches non-null objects other than arrays.
When to use
Use to match broad non-null, non-array object values.
Details
This predicate uses Predicate.isObject: it returns true for values whose
runtime type is "object", are not null, and are not arrays. It can match
Date, RegExp, and class instances; use instanceOf or a more specific
pattern when those cases need to be distinguished.
Example (Matching record objects)
import { Match } from "effect"
const analyzeValue = Match.type<unknown>().pipe(
Match.when(Match.record, (obj) => {
const keys = Object.keys(obj)
const valueCount = keys.length
return `Object with ${valueCount} properties: [${keys.join(", ")}]`
}),
Match.when(
Match.instanceOf(Array),
(arr) => `Array with ${arr.length} items`
),
Match.orElse(() => "Not an object")
)
console.log(analyzeValue({ name: "Alice", age: 30 })) // "Object with 2 properties: [name, age]"
console.log(analyzeValue([1, 2, 3])) // "Array with 3 items"
console.log(analyzeValue(null)) // "Not an object"
console.log(analyzeValue("hello")) // "Not an object"
record: import PredicatePredicate.interface Refinement<in A, out B extends A>A predicate that also narrows the input type when it returns true.
When to use
Use when you want a runtime check that refines A to B for TypeScript,
especially when composing type guards with
compose
or safely
checking unknown values.
Details
A refinement returns a type predicate (a is B). Use it with if or
filter to narrow types.
Example (Narrowing unknown values)
import { Predicate } from "effect"
const isString: Predicate.Refinement<unknown, string> = (u): u is string => typeof u === "string"
const data: unknown = "hello"
if (isString(data)) {
console.log(data.toUpperCase())
}
Type-level utilities for working with
Refinement
types.
When to use
Use when you need to extract input and output types from refinement
signatures while writing generic helpers over refinements.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting refinement types)
import { Predicate } from "effect"
type IsString = Predicate.Refinement<unknown, string>
type Input = Predicate.Refinement.In<IsString>
type Output = Predicate.Refinement.Out<IsString>
Refinement<unknown, { [x: PropertyKeyx: type PropertyKey =
| string
| number
| symbol
PropertyKey]: unknown }> = import PredicatePredicate.function isObject(
input: unknown
): input is {
[x: PropertyKey]: unknown
}
Checks whether a value is a non-null object value that is not an array.
When to use
Use to narrow unknown input to a non-null, non-array object with a
Predicate guard.
Details
This is a structural runtime check using typeof input === "object", so it
also accepts object instances such as Date, Map, class instances, and
typed arrays. It excludes null and arrays.
Example (Guarding objects)
import { Predicate } from "effect"
console.log(Predicate.isObject({ a: 1 }))
console.log(Predicate.isObject([1, 2]))
isObject