Hyperlinkv0.8.0-beta.28

Function

Function.absurdconsteffect/Function.ts:518
<A>(_: never): A

Marks an impossible branch by accepting a never value and returning any type.

When to use

Use when you need a return value in a branch that exhaustive checks prove cannot be reached.

Gotchas

Calling absurd throws, because a value of type never should be impossible at runtime.

Example (Handling impossible values)

import { absurd } from "effect"

const handleNever = (value: never) => {
  return absurd(value) // This will throw an error if called
}
utility types
export const absurd = <A>(_: never): A => {
  throw new Error("Called `absurd` function which should be uncallable")
}
Referenced by 1 symbols