@typed/fp
Version:
Data Structures and Resources for fp-ts
188 lines • 3.24 kB
JavaScript
import * as E from 'fp-ts/Either';
import { flow, pipe } from 'fp-ts/function';
import * as O from 'fp-ts/Option';
import * as OT from 'fp-ts/OptionT';
import * as R from './Resume';
/**
* @since 0.9.2
* @category Combinator
*/
export const alt = OT.alt(R.Monad);
/**
* @since 0.9.2
* @category Combinator
*/
export const ap = OT.ap(R.Apply);
/**
* @since 0.9.2
* @category Combinator
*/
export const chain = OT.chain(R.Monad);
/**
* @since 0.9.2
* @category Combinator
*/
export const chainNullableK = OT.chainNullableK(R.Monad);
/**
* @since 0.9.2
* @category Combinator
*/
export const chainOptionK = OT.chainOptionK(R.Monad);
/**
* @since 0.9.2
* @category Constructor
*/
export const fromEither = OT.fromEither(R.Monad);
/**
* @since 0.9.2
* @category Constructor
*/
export const fromResume = OT.fromF(R.Monad);
/**
* @since 0.9.2
* @category Constructor
*/
export const fromNullable = OT.fromNullable(R.Pointed);
/**
* @since 0.9.2
* @category Constructor
*/
export const fromNullableK = OT.fromNullableK(R.Pointed);
/**
* @since 0.9.2
* @category Constructor
*/
export const fromOptionK = OT.fromOptionK(R.Pointed);
/**
* @since 0.9.2
* @category Constructor
*/
export const fromPredicate = OT.fromPredicate(R.Pointed);
/**
* @since 0.9.2
* @category Deconstructor
*/
export const getOrElse = OT.getOrElse(R.Functor);
/**
* @since 0.9.2
* @category Deconstructor
*/
export const getOrElseE = OT.getOrElseE(R.Monad);
/**
* @since 0.9.2
* @category Combinator
*/
export const map = OT.map(R.Functor);
/**
* @since 0.9.2
* @category Deconstructor
*/
export const match = OT.match(R.Functor);
/**
* @since 0.9.2
* @category Deconstructor
*/
export const matchE = OT.matchE(R.Chain);
/**
* @since 0.9.2
* @category Constructor
*/
export const some = OT.some(R.Pointed);
/**
* @since 0.9.2
* @category Constructor
*/
export const zero = OT.zero(R.Pointed);
/**
* @since 0.9.2
* @category URI
*/
export const URI = '@typed/fp/ResumeOption';
/**
* @since 0.9.2
* @category Instance
*/
export const Pointed = {
of: flow(O.some, R.of),
};
/**
* @since 0.9.2
* @category Instance
*/
export const Functor = {
map,
};
/**
* @since 0.9.2
* @category Instance
*/
export const Apply = {
...Functor,
ap,
};
/**
* @since 0.9.2
* @category Instance
*/
export const Applicative = {
...Apply,
...Pointed,
};
/**
* @since 0.9.2
* @category Instance
*/
export const Chain = {
...Functor,
chain,
};
/**
* @since 0.9.2
* @category Combinator
*/
export const chainRec = (f) => R.chainRec(flow(f, R.map((oe) => {
if (O.isNone(oe)) {
return E.right(oe);
}
return pipe(oe.value, E.map(O.some));
})));
/**
* @since 0.9.2
* @category Instance
*/
export const ChainRec = {
chainRec,
};
/**
* @since 0.9.2
* @category Instance
*/
export const Monad = {
...Chain,
...Pointed,
};
/**
* @since 0.9.2
* @category Instance
*/
export const MonadRec = {
...Monad,
...ChainRec,
};
/**
* @since 0.9.2
* @category Instance
*/
export const Alt = {
...Functor,
alt,
};
/**
* @since 0.9.2
* @category Instance
*/
export const Alternative = {
...Alt,
zero,
};
//# sourceMappingURL=ResumeOption.js.map