Hyperlinkv0.8.0-beta.28

Cause

Cause.fromReasonsconsteffect/Cause.ts:431
<E>(reasons: ReadonlyArray<Reason<E>>): Cause<E>

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

  • Returns a new Cause.
  • An empty array produces a cause equivalent to empty.

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
constructorscombine
Source effect/Cause.ts:4313 lines
export const fromReasons: <E>(
  reasons: ReadonlyArray<Reason<E>>
) => Cause<E> = core.causeFromReasons
Referenced by 1 symbols