import * as Exit from "../../Exit.ts" import * as Option from "../../Option.ts" import { args } from "../core.ts" /** @internal */ export const missing: unique symbol = Symbol.for("effect/schema/parser/missing") /** @internal */ export { args } /** @internal */ export type Success = Exit.Success & { readonly [args]: A } /** @internal */ export const succeed = Exit.succeed as (value: A) => Success /** @internal */ export const missingExit = succeed(missing) // Cached success for an unchanged input. The missing symbol also brands the // result so module copies can recognize it without sharing the Exit object. // Resolve it before crossing an asynchronous or transformation boundary. /** @internal */ export const sameExit: Success = Object.assign(succeed(missing), { [missing]: true }) /** @internal */ export const isSameExit = (result: object): boolean => (result as { readonly [missing]?: boolean })[missing] === true /** @internal */ export const toOption = (value: A): Option.Option => value === missing ? Option.none() : Option.some(value as A) /** @internal */ export const fromOptionExit = (option: Option.Option): Success => option._tag === "None" ? missingExit : succeed(option.value)