版博士V2.0程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

817 wiersze
24 KiB

  1. /**
  2. * @since 2.0.0
  3. */
  4. import { Alt3, Alt3C } from './Alt'
  5. import { Applicative3, Applicative3C } from './Applicative'
  6. import { Apply3 } from './Apply'
  7. import { Bifunctor3 } from './Bifunctor'
  8. import { Chain3 } from './Chain'
  9. import { Compactable3C } from './Compactable'
  10. import * as E from './Either'
  11. import { Filterable3C } from './Filterable'
  12. import { FromEither3 } from './FromEither'
  13. import { FromReader3 } from './FromReader'
  14. import { Lazy } from './function'
  15. import { Functor3 } from './Functor'
  16. import { Monad3, Monad3C } from './Monad'
  17. import { MonadThrow3, MonadThrow3C } from './MonadThrow'
  18. import { Monoid } from './Monoid'
  19. import { Option } from './Option'
  20. import { Pointed3 } from './Pointed'
  21. import { Predicate } from './Predicate'
  22. import * as R from './Reader'
  23. import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'
  24. import { Refinement } from './Refinement'
  25. import { Semigroup } from './Semigroup'
  26. import Reader = R.Reader
  27. import Either = E.Either
  28. /**
  29. * @category model
  30. * @since 2.0.0
  31. */
  32. export interface ReaderEither<R, E, A> extends Reader<R, Either<E, A>> {}
  33. /**
  34. * @category constructors
  35. * @since 2.0.0
  36. */
  37. export declare const left: <R, E = never, A = never>(e: E) => ReaderEither<R, E, A>
  38. /**
  39. * @category constructors
  40. * @since 2.0.0
  41. */
  42. export declare const right: <R, E = never, A = never>(a: A) => ReaderEither<R, E, A>
  43. /**
  44. * @category constructors
  45. * @since 2.0.0
  46. */
  47. export declare const rightReader: <R, E = never, A = never>(ma: Reader<R, A>) => ReaderEither<R, E, A>
  48. /**
  49. * @category constructors
  50. * @since 2.0.0
  51. */
  52. export declare const leftReader: <R, E = never, A = never>(me: Reader<R, E>) => ReaderEither<R, E, A>
  53. /**
  54. * @category conversions
  55. * @since 2.0.0
  56. */
  57. export declare const fromEither: <E, A, R = unknown>(fa: Either<E, A>) => ReaderEither<R, E, A>
  58. /**
  59. * @category conversions
  60. * @since 2.11.0
  61. */
  62. export declare const fromReader: <R, A, E = never>(fa: Reader<R, A>) => ReaderEither<R, E, A>
  63. /**
  64. * @category pattern matching
  65. * @since 2.10.0
  66. */
  67. export declare const match: <E, B, A>(
  68. onLeft: (e: E) => B,
  69. onRight: (a: A) => B
  70. ) => <R>(ma: ReaderEither<R, E, A>) => Reader<R, B>
  71. /**
  72. * Less strict version of [`match`](#match).
  73. *
  74. * The `W` suffix (short for **W**idening) means that the handler return types will be merged.
  75. *
  76. * @category pattern matching
  77. * @since 2.10.0
  78. */
  79. export declare const matchW: <E, B, A, C>(
  80. onLeft: (e: E) => B,
  81. onRight: (a: A) => C
  82. ) => <R>(ma: Reader<R, Either<E, A>>) => Reader<R, B | C>
  83. /**
  84. * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`Reader`).
  85. *
  86. * @category pattern matching
  87. * @since 2.10.0
  88. */
  89. export declare const matchE: <R, E, A, B>(
  90. onLeft: (e: E) => Reader<R, B>,
  91. onRight: (a: A) => Reader<R, B>
  92. ) => (ma: ReaderEither<R, E, A>) => Reader<R, B>
  93. /**
  94. * Alias of [`matchE`](#matche).
  95. *
  96. * @category pattern matching
  97. * @since 2.0.0
  98. */
  99. export declare const fold: <R, E, A, B>(
  100. onLeft: (e: E) => R.Reader<R, B>,
  101. onRight: (a: A) => R.Reader<R, B>
  102. ) => (ma: ReaderEither<R, E, A>) => R.Reader<R, B>
  103. /**
  104. * Less strict version of [`matchE`](#matche).
  105. *
  106. * The `W` suffix (short for **W**idening) means that the handler return types will be merged.
  107. *
  108. * @category pattern matching
  109. * @since 2.10.0
  110. */
  111. export declare const matchEW: <E, R2, B, A, R3, C>(
  112. onLeft: (e: E) => Reader<R2, B>,
  113. onRight: (a: A) => Reader<R3, C>
  114. ) => <R1>(ma: ReaderEither<R1, E, A>) => Reader<R1 & R2 & R3, B | C>
  115. /**
  116. * Alias of [`matchEW`](#matchew).
  117. *
  118. * @category pattern matching
  119. * @since 2.10.0
  120. */
  121. export declare const foldW: <E, R2, B, A, R3, C>(
  122. onLeft: (e: E) => R.Reader<R2, B>,
  123. onRight: (a: A) => R.Reader<R3, C>
  124. ) => <R1>(ma: ReaderEither<R1, E, A>) => R.Reader<R1 & R2 & R3, B | C>
  125. /**
  126. * @category error handling
  127. * @since 2.0.0
  128. */
  129. export declare const getOrElse: <E, R, A>(onLeft: (e: E) => Reader<R, A>) => (ma: ReaderEither<R, E, A>) => Reader<R, A>
  130. /**
  131. * Less strict version of [`getOrElse`](#getorelse).
  132. *
  133. * The `W` suffix (short for **W**idening) means that the handler return type will be merged.
  134. *
  135. * @category error handling
  136. * @since 2.6.0
  137. */
  138. export declare const getOrElseW: <R2, E, B>(
  139. onLeft: (e: E) => Reader<R2, B>
  140. ) => <R1, A>(ma: ReaderEither<R1, E, A>) => Reader<R1 & R2, A | B>
  141. /**
  142. * @category conversions
  143. * @since 2.10.0
  144. */
  145. export declare const toUnion: <R, E, A>(fa: ReaderEither<R, E, A>) => Reader<R, E | A>
  146. /**
  147. * Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s
  148. * `contramap`).
  149. *
  150. * @since 2.0.0
  151. */
  152. export declare const local: <R2, R1>(f: (r2: R2) => R1) => <E, A>(ma: ReaderEither<R1, E, A>) => ReaderEither<R2, E, A>
  153. /**
  154. * Less strict version of [`asksReaderEither`](#asksreadereither).
  155. *
  156. * The `W` suffix (short for **W**idening) means that the environment types will be merged.
  157. *
  158. * @category constructors
  159. * @since 2.11.0
  160. */
  161. export declare const asksReaderEitherW: <R1, R2, E, A>(
  162. f: (r1: R1) => ReaderEither<R2, E, A>
  163. ) => ReaderEither<R1 & R2, E, A>
  164. /**
  165. * Effectfully accesses the environment.
  166. *
  167. * @category constructors
  168. * @since 2.11.0
  169. */
  170. export declare const asksReaderEither: <R, E, A>(f: (r: R) => ReaderEither<R, E, A>) => ReaderEither<R, E, A>
  171. /**
  172. * @category error handling
  173. * @since 2.0.0
  174. */
  175. export declare const orElse: <E1, R, E2, A>(
  176. onLeft: (e: E1) => ReaderEither<R, E2, A>
  177. ) => (ma: ReaderEither<R, E1, A>) => ReaderEither<R, E2, A>
  178. /**
  179. * Less strict version of [`orElse`](#orelse).
  180. *
  181. * The `W` suffix (short for **W**idening) means that the environment types and the return types will be merged.
  182. *
  183. * @category error handling
  184. * @since 2.10.0
  185. */
  186. export declare const orElseW: <E1, R1, E2, B>(
  187. onLeft: (e: E1) => ReaderEither<R1, E2, B>
  188. ) => <R2, A>(ma: ReaderEither<R2, E1, A>) => ReaderEither<R1 & R2, E2, A | B>
  189. /**
  190. * @category error handling
  191. * @since 2.11.0
  192. */
  193. export declare const orElseFirst: <E, R, B>(
  194. onLeft: (e: E) => ReaderEither<R, E, B>
  195. ) => <A>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>
  196. /**
  197. * The `W` suffix (short for **W**idening) means that the environment types and the return types will be merged.
  198. *
  199. * @category error handling
  200. * @since 2.11.0
  201. */
  202. export declare const orElseFirstW: <E1, R2, E2, B>(
  203. onLeft: (e: E1) => ReaderEither<R2, E2, B>
  204. ) => <R1, A>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, A>
  205. /**
  206. * @category error handling
  207. * @since 2.11.0
  208. */
  209. export declare const orLeft: <E1, R, E2>(
  210. onLeft: (e: E1) => Reader<R, E2>
  211. ) => <A>(fa: ReaderEither<R, E1, A>) => ReaderEither<R, E2, A>
  212. /**
  213. * @since 2.0.0
  214. */
  215. export declare const swap: <R, E, A>(ma: ReaderEither<R, E, A>) => ReaderEither<R, A, E>
  216. /**
  217. * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
  218. * use the type constructor `F` to represent some computational context.
  219. *
  220. * @category mapping
  221. * @since 2.0.0
  222. */
  223. export declare const map: <A, B>(f: (a: A) => B) => <R, E>(fa: ReaderEither<R, E, A>) => ReaderEither<R, E, B>
  224. /**
  225. * Map a pair of functions over the two last type arguments of the bifunctor.
  226. *
  227. * @category mapping
  228. * @since 2.0.0
  229. */
  230. export declare const bimap: <E, G, A, B>(
  231. f: (e: E) => G,
  232. g: (a: A) => B
  233. ) => <R>(fa: ReaderEither<R, E, A>) => ReaderEither<R, G, B>
  234. /**
  235. * Map a function over the second type argument of a bifunctor.
  236. *
  237. * @category error handling
  238. * @since 2.0.0
  239. */
  240. export declare const mapLeft: <E, G>(f: (e: E) => G) => <R, A>(fa: ReaderEither<R, E, A>) => ReaderEither<R, G, A>
  241. /**
  242. * @since 2.0.0
  243. */
  244. export declare const ap: <R, E, A>(
  245. fa: ReaderEither<R, E, A>
  246. ) => <B>(fab: ReaderEither<R, E, (a: A) => B>) => ReaderEither<R, E, B>
  247. /**
  248. * Less strict version of [`ap`](#ap).
  249. *
  250. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  251. *
  252. * @since 2.8.0
  253. */
  254. export declare const apW: <R2, E2, A>(
  255. fa: ReaderEither<R2, E2, A>
  256. ) => <R1, E1, B>(fab: ReaderEither<R1, E1, (a: A) => B>) => ReaderEither<R1 & R2, E1 | E2, B>
  257. /**
  258. * @category constructors
  259. * @since 2.8.5
  260. */
  261. export declare const of: <R = unknown, E = never, A = never>(a: A) => ReaderEither<R, E, A>
  262. /**
  263. * Composes computations in sequence, using the return value of one computation to determine the next computation.
  264. *
  265. * @category sequencing
  266. * @since 2.0.0
  267. */
  268. export declare const chain: <R, E, A, B>(
  269. f: (a: A) => ReaderEither<R, E, B>
  270. ) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>
  271. /**
  272. * Less strict version of [`chain`](#chain).
  273. *
  274. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  275. *
  276. * @category sequencing
  277. * @since 2.6.0
  278. */
  279. export declare const chainW: <R2, E2, A, B>(
  280. f: (a: A) => ReaderEither<R2, E2, B>
  281. ) => <R1, E1>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, B>
  282. /**
  283. * Less strict version of [`flatten`](#flatten).
  284. *
  285. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  286. *
  287. * @category sequencing
  288. * @since 2.11.0
  289. */
  290. export declare const flattenW: <R1, R2, E1, E2, A>(
  291. mma: ReaderEither<R1, E1, ReaderEither<R2, E2, A>>
  292. ) => ReaderEither<R1 & R2, E1 | E2, A>
  293. /**
  294. * @category sequencing
  295. * @since 2.0.0
  296. */
  297. export declare const flatten: <R, E, A>(mma: ReaderEither<R, E, ReaderEither<R, E, A>>) => ReaderEither<R, E, A>
  298. /**
  299. * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
  300. * types of kind `* -> *`.
  301. *
  302. * @category error handling
  303. * @since 2.0.0
  304. */
  305. export declare const alt: <R, E, A>(
  306. that: () => ReaderEither<R, E, A>
  307. ) => (fa: ReaderEither<R, E, A>) => ReaderEither<R, E, A>
  308. /**
  309. * Less strict version of [`alt`](#alt).
  310. *
  311. * The `W` suffix (short for **W**idening) means that the environment, the error and the return types will be merged.
  312. *
  313. * @category error handling
  314. * @since 2.9.0
  315. */
  316. export declare const altW: <R2, E2, B>(
  317. that: () => ReaderEither<R2, E2, B>
  318. ) => <R1, E1, A>(fa: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2, A | B>
  319. /**
  320. * @since 2.7.0
  321. */
  322. export declare const throwError: MonadThrow3<URI>['throwError']
  323. /**
  324. * @category type lambdas
  325. * @since 2.0.0
  326. */
  327. export declare const URI = 'ReaderEither'
  328. /**
  329. * @category type lambdas
  330. * @since 2.0.0
  331. */
  332. export declare type URI = typeof URI
  333. declare module './HKT' {
  334. interface URItoKind3<R, E, A> {
  335. readonly [URI]: ReaderEither<R, E, A>
  336. }
  337. }
  338. /**
  339. * @category filtering
  340. * @since 2.10.0
  341. */
  342. export declare const getCompactable: <E>(M: Monoid<E>) => Compactable3C<'ReaderEither', E>
  343. /**
  344. * @category filtering
  345. * @since 2.10.0
  346. */
  347. export declare function getFilterable<E>(M: Monoid<E>): Filterable3C<URI, E>
  348. /**
  349. * The default [`Applicative`](#applicative) instance returns the first error, if you want to
  350. * get all errors you need to provide a way to concatenate them via a `Semigroup`.
  351. *
  352. * See [`getApplicativeValidation`](./Either.ts.html#getapplicativevalidation).
  353. *
  354. * @category error handling
  355. * @since 2.7.0
  356. */
  357. export declare function getApplicativeReaderValidation<E>(S: Semigroup<E>): Applicative3C<URI, E>
  358. /**
  359. * The default [`Alt`](#alt) instance returns the last error, if you want to
  360. * get all errors you need to provide a way to concatenate them via a `Semigroup`.
  361. *
  362. * See [`getAltValidation`](./Either.ts.html#getaltvalidation).
  363. *
  364. * @category error handling
  365. * @since 2.7.0
  366. */
  367. export declare function getAltReaderValidation<E>(S: Semigroup<E>): Alt3C<URI, E>
  368. /**
  369. * @category instances
  370. * @since 2.7.0
  371. */
  372. export declare const Functor: Functor3<URI>
  373. /**
  374. * @category mapping
  375. * @since 2.10.0
  376. */
  377. export declare const flap: <A>(a: A) => <R, E, B>(fab: ReaderEither<R, E, (a: A) => B>) => ReaderEither<R, E, B>
  378. /**
  379. * @category instances
  380. * @since 2.10.0
  381. */
  382. export declare const Pointed: Pointed3<URI>
  383. /**
  384. * @category instances
  385. * @since 2.10.0
  386. */
  387. export declare const Apply: Apply3<URI>
  388. /**
  389. * Combine two effectful actions, keeping only the result of the first.
  390. *
  391. * @since 2.0.0
  392. */
  393. export declare const apFirst: <R, E, B>(
  394. second: ReaderEither<R, E, B>
  395. ) => <A>(first: ReaderEither<R, E, A>) => ReaderEither<R, E, A>
  396. /**
  397. * Less strict version of [`apFirst`](#apfirst)
  398. *
  399. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  400. *
  401. * @since 2.12.0
  402. */
  403. export declare const apFirstW: <R2, E2, B>(
  404. second: ReaderEither<R2, E2, B>
  405. ) => <R1, E1, A>(first: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, A>
  406. /**
  407. * Combine two effectful actions, keeping only the result of the second.
  408. *
  409. * @since 2.0.0
  410. */
  411. export declare const apSecond: <R, E, B>(
  412. second: ReaderEither<R, E, B>
  413. ) => <A>(first: ReaderEither<R, E, A>) => ReaderEither<R, E, B>
  414. /**
  415. * Less strict version of [`apSecond`](#apsecond)
  416. *
  417. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  418. *
  419. * @since 2.12.0
  420. */
  421. export declare const apSecondW: <R2, E2, B>(
  422. second: ReaderEither<R2, E2, B>
  423. ) => <R1, E1, A>(first: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, B>
  424. /**
  425. * @category instances
  426. * @since 2.7.0
  427. */
  428. export declare const Applicative: Applicative3<URI>
  429. /**
  430. * @category instances
  431. * @since 2.10.0
  432. */
  433. export declare const Chain: Chain3<URI>
  434. /**
  435. * @category instances
  436. * @since 2.7.0
  437. */
  438. export declare const Monad: Monad3<URI>
  439. /**
  440. * Composes computations in sequence, using the return value of one computation to determine the next computation and
  441. * keeping only the result of the first.
  442. *
  443. * @category sequencing
  444. * @since 2.0.0
  445. */
  446. export declare const chainFirst: <R, E, A, B>(
  447. f: (a: A) => ReaderEither<R, E, B>
  448. ) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>
  449. /**
  450. * Less strict version of [`chainFirst`](#chainfirst)
  451. *
  452. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  453. *
  454. * @category sequencing
  455. * @since 2.8.0
  456. */
  457. export declare const chainFirstW: <R2, E2, A, B>(
  458. f: (a: A) => ReaderEither<R2, E2, B>
  459. ) => <R1, E1>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, A>
  460. /**
  461. * @category instances
  462. * @since 2.7.0
  463. */
  464. export declare const Bifunctor: Bifunctor3<URI>
  465. /**
  466. * @category instances
  467. * @since 2.7.0
  468. */
  469. export declare const Alt: Alt3<URI>
  470. /**
  471. * @category instances
  472. * @since 2.11.0
  473. */
  474. export declare const FromReader: FromReader3<URI>
  475. /**
  476. * Reads the current context.
  477. *
  478. * @category constructors
  479. * @since 2.0.0
  480. */
  481. export declare const ask: <R, E = never>() => ReaderEither<R, E, R>
  482. /**
  483. * Projects a value from the global context in a `ReaderEither`.
  484. *
  485. * @category constructors
  486. * @since 2.0.0
  487. */
  488. export declare const asks: <R, A, E = never>(f: (r: R) => A) => ReaderEither<R, E, A>
  489. /**
  490. * @category lifting
  491. * @since 2.11.0
  492. */
  493. export declare const fromReaderK: <A extends ReadonlyArray<unknown>, R, B>(
  494. f: (...a: A) => Reader<R, B>
  495. ) => <E = never>(...a: A) => ReaderEither<R, E, B>
  496. /**
  497. * @category sequencing
  498. * @since 2.11.0
  499. */
  500. export declare const chainReaderK: <A, R, B>(
  501. f: (a: A) => Reader<R, B>
  502. ) => <E>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>
  503. /**
  504. * Less strict version of [`chainReaderK`](#chainreaderk).
  505. *
  506. * The `W` suffix (short for **W**idening) means that the environment types will be merged.
  507. *
  508. * @category sequencing
  509. * @since 2.11.0
  510. */
  511. export declare const chainReaderKW: <A, R2, B>(
  512. f: (a: A) => Reader<R2, B>
  513. ) => <R1, E>(ma: ReaderEither<R1, E, A>) => ReaderEither<R1 & R2, E, B>
  514. /**
  515. * @category sequencing
  516. * @since 2.11.0
  517. */
  518. export declare const chainFirstReaderK: <A, R, B>(
  519. f: (a: A) => Reader<R, B>
  520. ) => <E>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>
  521. /**
  522. * Less strict version of [`chainReaderK`](#chainreaderk).
  523. *
  524. * The `W` suffix (short for **W**idening) means that the environment types will be merged.
  525. *
  526. * @category sequencing
  527. * @since 2.11.0
  528. */
  529. export declare const chainFirstReaderKW: <A, R1, B>(
  530. f: (a: A) => Reader<R1, B>
  531. ) => <R2, E>(ma: ReaderEither<R2, E, A>) => ReaderEither<R1 & R2, E, A>
  532. /**
  533. * @category instances
  534. * @since 2.7.0
  535. */
  536. export declare const MonadThrow: MonadThrow3<URI>
  537. /**
  538. * @category instances
  539. * @since 2.10.0
  540. */
  541. export declare const FromEither: FromEither3<URI>
  542. /**
  543. * @category conversions
  544. * @since 2.0.0
  545. */
  546. export declare const fromOption: <E>(onNone: Lazy<E>) => <A, R = unknown>(fa: Option<A>) => ReaderEither<R, E, A>
  547. /**
  548. * @category lifting
  549. * @since 2.10.0
  550. */
  551. export declare const fromOptionK: <E>(
  552. onNone: Lazy<E>
  553. ) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R = unknown>(...a: A) => ReaderEither<R, E, B>
  554. /**
  555. * @category sequencing
  556. * @since 2.10.0
  557. */
  558. export declare const chainOptionK: <E>(
  559. onNone: Lazy<E>
  560. ) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>
  561. /**
  562. * @category sequencing
  563. * @since 2.4.0
  564. */
  565. export declare const chainEitherK: <E, A, B>(
  566. f: (a: A) => E.Either<E, B>
  567. ) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>
  568. /**
  569. * Less strict version of [`chainEitherK`](#chaineitherk).
  570. *
  571. * The `W` suffix (short for **W**idening) means that the error types will be merged.
  572. *
  573. * @category sequencing
  574. * @since 2.6.1
  575. */
  576. export declare const chainEitherKW: <E2, A, B>(
  577. f: (a: A) => Either<E2, B>
  578. ) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E1 | E2, B>
  579. /**
  580. * @category sequencing
  581. * @since 2.12.0
  582. */
  583. export declare const chainFirstEitherK: <A, E, B>(
  584. f: (a: A) => E.Either<E, B>
  585. ) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>
  586. /**
  587. * Less strict version of [`chainFirstEitherK`](#chainfirsteitherk).
  588. *
  589. * The `W` suffix (short for **W**idening) means that the environment types will be merged.
  590. *
  591. * @category sequencing
  592. * @since 2.12.0
  593. */
  594. export declare const chainFirstEitherKW: <A, E2, B>(
  595. f: (a: A) => Either<E2, B>
  596. ) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E1 | E2, A>
  597. /**
  598. * @category lifting
  599. * @since 2.0.0
  600. */
  601. export declare const fromPredicate: {
  602. <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderEither<R, E, B>
  603. <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown, B extends A = A>(b: B) => ReaderEither<R, E, B>
  604. <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderEither<R, E, A>
  605. }
  606. /**
  607. * @category filtering
  608. * @since 2.0.0
  609. */
  610. export declare const filterOrElse: {
  611. <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(
  612. ma: ReaderEither<R, E, A>
  613. ) => ReaderEither<R, E, B>
  614. <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(
  615. mb: ReaderEither<R, E, B>
  616. ) => ReaderEither<R, E, B>
  617. <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>
  618. }
  619. /**
  620. * Less strict version of [`filterOrElse`](#filterorelse).
  621. *
  622. * The `W` suffix (short for **W**idening) means that the error types will be merged.
  623. *
  624. * @category filtering
  625. * @since 2.9.0
  626. */
  627. export declare const filterOrElseW: {
  628. <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <R, E1>(
  629. ma: ReaderEither<R, E1, A>
  630. ) => ReaderEither<R, E1 | E2, B>
  631. <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1, B extends A>(
  632. mb: ReaderEither<R, E1, B>
  633. ) => ReaderEither<R, E1 | E2, B>
  634. <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1>(
  635. ma: ReaderEither<R, E1, A>
  636. ) => ReaderEither<R, E1 | E2, A>
  637. }
  638. /**
  639. * @category lifting
  640. * @since 2.4.0
  641. */
  642. export declare const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(
  643. f: (...a: A) => E.Either<E, B>
  644. ) => <R = unknown>(...a: A) => ReaderEither<R, E, B>
  645. /**
  646. * @category do notation
  647. * @since 2.9.0
  648. */
  649. export declare const Do: ReaderEither<unknown, never, {}>
  650. /**
  651. * @category do notation
  652. * @since 2.8.0
  653. */
  654. export declare const bindTo: <N extends string>(
  655. name: N
  656. ) => <R, E, A>(fa: ReaderEither<R, E, A>) => ReaderEither<R, E, { readonly [K in N]: A }>
  657. declare const let_: <N extends string, A, B>(
  658. name: Exclude<N, keyof A>,
  659. f: (a: A) => B
  660. ) => <R, E>(
  661. fa: ReaderEither<R, E, A>
  662. ) => ReaderEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
  663. export {
  664. /**
  665. * @category do notation
  666. * @since 2.13.0
  667. */
  668. let_ as let
  669. }
  670. /**
  671. * @category do notation
  672. * @since 2.8.0
  673. */
  674. export declare const bind: <N extends string, A, R, E, B>(
  675. name: Exclude<N, keyof A>,
  676. f: (a: A) => ReaderEither<R, E, B>
  677. ) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
  678. /**
  679. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  680. *
  681. * @category do notation
  682. * @since 2.8.0
  683. */
  684. export declare const bindW: <N extends string, A, R2, E2, B>(
  685. name: Exclude<N, keyof A>,
  686. f: (a: A) => ReaderEither<R2, E2, B>
  687. ) => <R1, E1>(
  688. fa: ReaderEither<R1, E1, A>
  689. ) => ReaderEither<
  690. R1 & R2,
  691. E1 | E2,
  692. {
  693. readonly [K in keyof A | N]: K extends keyof A ? A[K] : B
  694. }
  695. >
  696. /**
  697. * @category do notation
  698. * @since 2.8.0
  699. */
  700. export declare const apS: <N extends string, A, R, E, B>(
  701. name: Exclude<N, keyof A>,
  702. fb: ReaderEither<R, E, B>
  703. ) => (fa: ReaderEither<R, E, A>) => ReaderEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
  704. /**
  705. * Less strict version of [`apS`](#aps).
  706. *
  707. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  708. *
  709. * @category do notation
  710. * @since 2.8.0
  711. */
  712. export declare const apSW: <A, N extends string, R2, E2, B>(
  713. name: Exclude<N, keyof A>,
  714. fb: ReaderEither<R2, E2, B>
  715. ) => <R1, E1>(
  716. fa: ReaderEither<R1, E1, A>
  717. ) => ReaderEither<
  718. R1 & R2,
  719. E1 | E2,
  720. {
  721. readonly [K in keyof A | N]: K extends keyof A ? A[K] : B
  722. }
  723. >
  724. /**
  725. * @since 2.11.0
  726. */
  727. export declare const ApT: ReaderEither<unknown, never, readonly []>
  728. /**
  729. * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.
  730. *
  731. * @category traversing
  732. * @since 2.11.0
  733. */
  734. export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, E, B>(
  735. f: (index: number, a: A) => ReaderEither<R, E, B>
  736. ) => (as: ReadonlyNonEmptyArray<A>) => ReaderEither<R, E, ReadonlyNonEmptyArray<B>>
  737. /**
  738. * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.
  739. *
  740. * @category traversing
  741. * @since 2.11.0
  742. */
  743. export declare const traverseReadonlyArrayWithIndex: <A, R, E, B>(
  744. f: (index: number, a: A) => ReaderEither<R, E, B>
  745. ) => (as: readonly A[]) => ReaderEither<R, E, readonly B[]>
  746. /**
  747. * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.
  748. *
  749. * @category traversing
  750. * @since 2.9.0
  751. */
  752. export declare const traverseArrayWithIndex: <R, E, A, B>(
  753. f: (index: number, a: A) => ReaderEither<R, E, B>
  754. ) => (as: ReadonlyArray<A>) => ReaderEither<R, E, ReadonlyArray<B>>
  755. /**
  756. * Equivalent to `ReadonlyArray#traverse(Applicative)`.
  757. *
  758. * @category traversing
  759. * @since 2.9.0
  760. */
  761. export declare const traverseArray: <R, E, A, B>(
  762. f: (a: A) => ReaderEither<R, E, B>
  763. ) => (as: readonly A[]) => ReaderEither<R, E, readonly B[]>
  764. /**
  765. * Equivalent to `ReadonlyArray#sequence(Applicative)`.
  766. *
  767. * @category traversing
  768. * @since 2.9.0
  769. */
  770. export declare const sequenceArray: <R, E, A>(
  771. arr: ReadonlyArray<ReaderEither<R, E, A>>
  772. ) => ReaderEither<R, E, ReadonlyArray<A>>
  773. /**
  774. * This instance is deprecated, use small, specific instances instead.
  775. * For example if a function needs a `Functor` instance, pass `RE.Functor` instead of `RE.readerEither`
  776. * (where `R` is from `import R from 'fp-ts/ReaderEither'`)
  777. *
  778. * @category zone of death
  779. * @since 2.0.0
  780. * @deprecated
  781. */
  782. export declare const readerEither: Monad3<URI> & Bifunctor3<URI> & Alt3<URI> & MonadThrow3<URI>
  783. /**
  784. * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.
  785. *
  786. * @category zone of death
  787. * @since 2.0.0
  788. * @deprecated
  789. */
  790. export declare const getApplySemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderEither<R, E, A>>
  791. /**
  792. * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.
  793. *
  794. * @category zone of death
  795. * @since 2.0.0
  796. * @deprecated
  797. */
  798. export declare const getApplyMonoid: <R, E, A>(M: Monoid<A>) => Monoid<ReaderEither<R, E, A>>
  799. /**
  800. * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.
  801. *
  802. * @category zone of death
  803. * @since 2.0.0
  804. * @deprecated
  805. */
  806. export declare const getSemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderEither<R, E, A>>
  807. /**
  808. * Use [`getApplicativeReaderValidation`](#getapplicativereadervalidation) and [`getAltReaderValidation`](#getaltreadervalidation) instead.
  809. *
  810. * @category zone of death
  811. * @since 2.3.0
  812. * @deprecated
  813. */
  814. export declare function getReaderValidation<E>(
  815. SE: Semigroup<E>
  816. ): Monad3C<URI, E> & Bifunctor3<URI> & Alt3C<URI, E> & MonadThrow3C<URI, E>