UNPKG

fp-ts-std

Version:

The missing pseudo-standard library for fp-ts.

66 lines 1.71 kB
/** * Utility functions to accommodate `fp-ts/IOOption`. * * @since 0.16.0 */ import * as IOO from "fp-ts/IOOption"; type IOOption<A> = IOO.IOOption<A>; /** * Unwrap the value from within an `IOOption`, throwing if `None`. * * @example * import { unsafeUnwrap } from 'fp-ts-std/IOOption' * import * as IOO from 'fp-ts/IOOption' * * assert.strictEqual(unsafeUnwrap(IOO.some(5)), 5) * * @category 3 Functions * @since 0.16.0 */ export declare const unsafeUnwrap: <A>(x: IOOption<A>) => A; /** * Unwrap the value from within an `IOOption`, throwing `msg` if `None`. * * @example * import { unsafeExpect } from 'fp-ts-std/IOOption' * import * as IOO from 'fp-ts/IOOption' * * assert.throws( * () => unsafeExpect('foo')(IOO.none), * Error('Unwrapped `None`', { cause: 'foo' }), * ) * * @category 3 Functions * @since 0.16.0 */ export declare const unsafeExpect: (msg: string) => <A>(x: IOOption<A>) => A; /** * Convenient alias for `IOO.of(undefined)`. * * @example * import { flow, pipe, constant } from 'fp-ts/function' * import * as Fn from 'fp-ts-std/Function' * import * as O from 'fp-ts/Option' * import Option = O.Option * import * as IOO from 'fp-ts/IOOption' * import IOOption = IOO.IOOption * import { pass } from 'fp-ts-std/IOOption' * import { log } from 'fp-ts/Console' * * const mcount: Option<number> = O.some(123) * const tryLog: <A>(x: A) => IOOption<void> = flow(log, IOO.fromIO) * * const logCount: IOOption<void> = pipe( * mcount, * O.match( * constant(pass), * tryLog, * ), * ) * * @category 2 Typeclass Methods * @since 0.17.0 */ export declare const pass: IOOption<void>; export {}; //# sourceMappingURL=IOOption.d.ts.map