import * as E from "../Either"; import * as O from "../Option"; import * as X from "../XPure"; import type { Sync } from "./model"; /* * ------------------------------------------- * Sync Constructors * ------------------------------------------- */ export const succeed: (a: A) => Sync = X.succeed; export const fail: (e: E) => Sync = X.fail; export const total: (thunk: () => A) => Sync = X.total; export const partial_: (thunk: () => A, onThrow: (error: unknown) => E) => Sync = X.partial_; export const partial: (onThrow: (error: unknown) => E) => (thunk: () => A) => Sync = X.partial; export const suspend: (factory: () => Sync) => Sync = X.suspend; export const fromEither: (either: E.Either) => Sync = E.fold(fail, succeed); export const fromOption = (option: O.Option, onNone: () => E): Sync => O.fold_(option, () => fail(onNone()), succeed);