UNPKG

effect-ts-laws

Version:
28 lines 856 B
/** * Arbitraries for effectful datatypes. * @module */ import { pipe } from 'effect'; import * as EF from 'effect/Effect'; import fc from 'fast-check'; import { Monad as arbitraryMonad } from './instances.js'; const { map } = arbitraryMonad; /** * Convert an arbitrary of `T` into a successful effect of `T`. * @category arbitraries */ export const succeed = a => pipe(a, map(EF.succeed)); /** * Convert an arbitrary of a string error message into a fail effect. * @category arbitraries */ export const fail = map(m => EF.fail(new Error(m))); /** * Convert an arbitrary of a string error message and an arbitrary of `T` * into a sync effect, possibly suspended. * @category arbitraries */ export const sync = (a, message) => fc .oneof(succeed(a), fail(message)) .map(sync => EF.suspend(() => sync)); //# sourceMappingURL=effect.js.map