版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FromReader.js 673 B

123456789101112131415161718192021222324
  1. /**
  2. * Lift a computation from the `Reader` monad.
  3. *
  4. * @since 2.11.0
  5. */
  6. import { chainFirst } from './Chain';
  7. import { flow } from './function';
  8. import * as R from './Reader';
  9. export function ask(F) {
  10. return function () { return F.fromReader(R.ask()); };
  11. }
  12. export function asks(F) {
  13. return F.fromReader;
  14. }
  15. export function fromReaderK(F) {
  16. return function (f) { return flow(f, F.fromReader); };
  17. }
  18. export function chainReaderK(F, M) {
  19. var fromReaderKF = fromReaderK(F);
  20. return function (f) { return function (ma) { return M.chain(ma, fromReaderKF(f)); }; };
  21. }
  22. export function chainFirstReaderK(F, M) {
  23. return flow(fromReaderK(F), chainFirst(M));
  24. }