Hyperlinkv0.8.0-beta.28

Predicate

Predicate.isNotNullfunctioneffect/Predicate.ts:861
<A>(input: A): input is Exclude<A, null>

Checks whether a value is not null.

When to use

Use when you need a Predicate refinement that filters out null while preserving other falsy values.

Details

Returns a refinement that excludes null.

Example (Filtering null values)

import { Predicate } from "effect"

const values = [1, null, 2]
const nonNull = values.filter(Predicate.isNotNull)

console.log(nonNull)
export function isNotNull<A>(input: A): input is Exclude<A, null> {
  return input !== null
}