// ets_tracing: off import { asUnit } from "./asUnit.js" import { chain_, suspend, unit } from "./core.js" import type { Effect } from "./effect.js" /** * The moral equivalent of `if (!p) exp` * * @ets_data_first unless_ */ export function unless(b: () => boolean, __trace?: string) { return (self: Effect) => suspend(() => (b() ? unit : asUnit(self)), __trace) } /** * The moral equivalent of `if (!p) exp` */ export function unless_( self: Effect, b: () => boolean, __trace?: string ) { return suspend(() => (b() ? unit : asUnit(self)), __trace) } /** * The moral equivalent of `if (!p) exp` when `p` has side-effects * * @ets_data_first unlessM_ */ export function unlessM(b: Effect, __trace?: string) { return (self: Effect) => unlessM_(self, b, __trace) } /** * The moral equivalent of `if (!p) exp` when `p` has side-effects */ export function unlessM_( self: Effect, b: Effect, __trace?: string ) { return chain_(b, (_) => (_ ? unit : asUnit(self)), __trace) }