effect-io-ai

Package: effect
Module: Cause

Cause.fromReasons

Creates a Cause from an array of Reason values.

When to use

Use when you already have individual reasons (e.g. from filtering or transforming another cause’s reasons array) and need to wrap them back into a Cause.

Details

Gotchas

The reasons array is stored as provided. Treat the array as immutable after passing it to this function.

Example (Building a cause from reasons)

import { Cause } from "effect"

const reasons = [
  Cause.makeFailReason("err1"),
  Cause.makeFailReason("err2")
]
const cause = Cause.fromReasons(reasons)
console.log(cause.reasons.length) // 2

See

Signature

declare const fromReasons: <E>(reasons: ReadonlyArray<Reason<E>>) => Cause<E>

Source

Since v4.0.0