// ets_tracing: off import { chain_, succeed, suspend } from "./core.js" import type { Effect } from "./effect.js" /** * Run conditionally onTrue or onFalse * * @ets_data_first ifM_ */ export function ifM( onTrue: () => Effect, onFalse: () => Effect, __trace?: string ) { return (b: Effect) => ifM_(b, onTrue, onFalse, __trace) } /** * Run conditionally onTrue or onFalse */ export function ifM_( b: Effect, onTrue: () => Effect, onFalse: () => Effect, __trace?: string ) { return chain_( b, (x): Effect => x ? suspend(onTrue, __trace) : suspend(onFalse, __trace) ) } /** * Run conditionally onTrue or onFalse * * @ets_data_first if_ */ function _if( onTrue: () => Effect, onFalse: () => Effect, __trace?: string ) { return (b: boolean) => if_(b, onTrue, onFalse, __trace) } /** * Run conditionally onTrue or onFalse */ export function if_( b: boolean, onTrue: () => Effect, onFalse: () => Effect, __trace?: string ) { return ifM_(succeed(b), onTrue, onFalse, __trace) } export { _if as if }