// ets_tracing: off import * as O from "../Option/index.js" import type { Sync as Effect } from "./core.js" import { fail, foldM_, succeed } from "./core.js" /** * Converts an option on errors into an option on values. */ export function optional( self: Effect, A> ): Effect> { return foldM_( self, O.fold(() => succeed(O.none), fail), (a) => succeed(O.some(a)) ) }