// ets_tracing: off import { constant, pipe } from "../Function/index.js" import * as O from "../Option/index.js" import { chain_, succeed } from "./core.js" import type { Effect } from "./effect.js" /** * Extracts the optional value, or executes the effect 'orElse'. * * @ets_data_first someOrElseM_ */ export function someOrElseM(orElse: Effect, __trace?: string) { return (self: Effect>) => someOrElseM_(self, orElse, __trace) } /** * Extracts the optional value, or executes the effect 'orElse'. */ export function someOrElseM_( self: Effect>, orElse: Effect, __trace?: string ): Effect { return chain_( self as Effect>, (x) => pipe(x, O.map(succeed), O.getOrElse(constant(orElse))), __trace ) }