diff --git a/src/Cause.ts b/src/Cause.ts index af61117..54012a1 100644 --- a/src/Cause.ts +++ b/src/Cause.ts @@ -3,17 +3,17 @@ import * as $Type from './Type' import { Variant } from './Type' import { FiberId } from './fiber/FiberId' -export type Cause = Fail | Die | Interrupt +export type Cause = Die | Fail | Interrupt type _Cause = Variant -export interface Fail extends _Cause<'Fail'> { - readonly error: E +export interface Die extends _Cause<'Die'> { + readonly error: unknown readonly fiberId: FiberId } -export interface Die extends _Cause<'Die'> { - readonly error: unknown +export interface Fail extends _Cause<'Fail'> { + readonly error: E readonly fiberId: FiberId } @@ -24,14 +24,14 @@ export interface Interrupt extends _Cause<'Interrupt'> { const uri = Symbol('Cause') const _cause = $Type.variant(uri) -export function fail(error: E, fiberId: FiberId): Cause { - return { ..._cause('Fail'), error, fiberId } -} - export function die(error: unknown, fiberId: FiberId): Cause { return { ..._cause('Die'), error, fiberId } } +export function fail(error: E, fiberId: FiberId): Cause { + return { ..._cause('Fail'), error, fiberId } +} + export function interrupt(fiberId: FiberId): Cause { return { ..._cause('Interrupt'), fiberId } } @@ -40,14 +40,14 @@ export function is(u: unknown): u is Cause { return $Struct.is(u) && $Struct.has(u, $Type.uri) && u[$Type.uri] === uri } -export function isFail(cause: Cause): cause is Fail { - return cause[$Type.tag] === 'Fail' -} - export function isDie(cause: Cause): cause is Die { return cause[$Type.tag] === 'Die' } +export function isFail(cause: Cause): cause is Fail { + return cause[$Type.tag] === 'Fail' +} + export function isInterrupt(cause: Cause): cause is Interrupt { return cause[$Type.tag] === 'Interrupt' }