版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

948 строки
29 KiB

  1. /**
  2. * @since 2.0.0
  3. */
  4. import { Alt4 } from './Alt'
  5. import { Applicative4 } from './Applicative'
  6. import { Apply4 } from './Apply'
  7. import { Bifunctor4 } from './Bifunctor'
  8. import { Chain4 } from './Chain'
  9. import * as E from './Either'
  10. import { Endomorphism } from './Endomorphism'
  11. import { FromEither4 } from './FromEither'
  12. import { FromIO4 } from './FromIO'
  13. import { FromReader4 } from './FromReader'
  14. import { FromState4 } from './FromState'
  15. import { FromTask4 } from './FromTask'
  16. import { Lazy } from './function'
  17. import { Functor4 } from './Functor'
  18. import { IO } from './IO'
  19. import { IOEither } from './IOEither'
  20. import { Monad4 } from './Monad'
  21. import { MonadIO4 } from './MonadIO'
  22. import { MonadTask4 } from './MonadTask'
  23. import { MonadThrow4 } from './MonadThrow'
  24. import { Option } from './Option'
  25. import { Pointed4 } from './Pointed'
  26. import { Predicate } from './Predicate'
  27. import * as R from './Reader'
  28. import { ReaderEither } from './ReaderEither'
  29. import * as RTE from './ReaderTaskEither'
  30. import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'
  31. import { Refinement } from './Refinement'
  32. import { State } from './State'
  33. import { Task } from './Task'
  34. import { TaskEither } from './TaskEither'
  35. import ReaderTaskEither = RTE.ReaderTaskEither
  36. import Either = E.Either
  37. import Reader = R.Reader
  38. /**
  39. * @category model
  40. * @since 2.0.0
  41. */
  42. export interface StateReaderTaskEither<S, R, E, A> {
  43. (s: S): ReaderTaskEither<R, E, [A, S]>
  44. }
  45. /**
  46. * @category constructors
  47. * @since 2.0.0
  48. */
  49. export declare const left: <S, R, E, A = never>(e: E) => StateReaderTaskEither<S, R, E, A>
  50. /**
  51. * @category constructors
  52. * @since 2.0.0
  53. */
  54. export declare const right: <S, R, E = never, A = never>(a: A) => StateReaderTaskEither<S, R, E, A>
  55. /**
  56. * @category constructors
  57. * @since 2.0.0
  58. */
  59. export declare function rightTask<S, R, E = never, A = never>(ma: Task<A>): StateReaderTaskEither<S, R, E, A>
  60. /**
  61. * @category constructors
  62. * @since 2.0.0
  63. */
  64. export declare function leftTask<S, R, E, A = never>(me: Task<E>): StateReaderTaskEither<S, R, E, A>
  65. /**
  66. * @category constructors
  67. * @since 2.0.0
  68. */
  69. export declare function rightReader<S, R, E = never, A = never>(ma: Reader<R, A>): StateReaderTaskEither<S, R, E, A>
  70. /**
  71. * @category constructors
  72. * @since 2.0.0
  73. */
  74. export declare function leftReader<S, R, E, A = never>(me: Reader<R, E>): StateReaderTaskEither<S, R, E, A>
  75. /**
  76. * @category constructors
  77. * @since 2.0.0
  78. */
  79. export declare function rightIO<S, R, E = never, A = never>(ma: IO<A>): StateReaderTaskEither<S, R, E, A>
  80. /**
  81. * @category constructors
  82. * @since 2.0.0
  83. */
  84. export declare function leftIO<S, R, E, A = never>(me: IO<E>): StateReaderTaskEither<S, R, E, A>
  85. /**
  86. * @category constructors
  87. * @since 2.0.0
  88. */
  89. export declare const rightState: <S, R, E = never, A = never>(ma: State<S, A>) => StateReaderTaskEither<S, R, E, A>
  90. /**
  91. * @category constructors
  92. * @since 2.0.0
  93. */
  94. export declare const leftState: <S, R, E, A = never>(me: State<S, E>) => StateReaderTaskEither<S, R, E, A>
  95. /**
  96. * @category conversions
  97. * @since 2.0.0
  98. */
  99. export declare const fromEither: <E, A, S, R = unknown>(fa: Either<E, A>) => StateReaderTaskEither<S, R, E, A>
  100. /**
  101. * @category conversions
  102. * @since 2.11.0
  103. */
  104. export declare const fromReader: <R, A, S, E = never>(fa: Reader<R, A>) => StateReaderTaskEither<S, R, E, A>
  105. /**
  106. * @category conversions
  107. * @since 2.7.0
  108. */
  109. export declare const fromIO: <A, S, R = unknown, E = never>(fa: IO<A>) => StateReaderTaskEither<S, R, E, A>
  110. /**
  111. * @category conversions
  112. * @since 2.7.0
  113. */
  114. export declare const fromTask: <A, S, R = unknown, E = never>(fa: Task<A>) => StateReaderTaskEither<S, R, E, A>
  115. /**
  116. * @category conversions
  117. * @since 2.10.0
  118. */
  119. export declare const fromState: <S, A, R = unknown, E = never>(fa: State<S, A>) => StateReaderTaskEither<S, R, E, A>
  120. /**
  121. * @category conversions
  122. * @since 2.0.0
  123. */
  124. export declare const fromTaskEither: <E, A, S, R = unknown>(fa: TaskEither<E, A>) => StateReaderTaskEither<S, R, E, A>
  125. /**
  126. * @category conversions
  127. * @since 2.0.0
  128. */
  129. export declare const fromIOEither: <E, A, S, R = unknown>(fa: IOEither<E, A>) => StateReaderTaskEither<S, R, E, A>
  130. /**
  131. * @category conversions
  132. * @since 2.0.0
  133. */
  134. export declare const fromReaderEither: <R, E, A, S>(fa: ReaderEither<R, E, A>) => StateReaderTaskEither<S, R, E, A>
  135. /**
  136. * @category constructors
  137. * @since 2.0.0
  138. */
  139. export declare const fromReaderTaskEither: <R, E, A, S>(
  140. fa: ReaderTaskEither<R, E, A>
  141. ) => StateReaderTaskEither<S, R, E, A>
  142. /**
  143. * Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s
  144. * `contramap`).
  145. *
  146. * @since 2.11.0
  147. */
  148. export declare const local: <R2, R1>(
  149. f: (r2: R2) => R1
  150. ) => <S, E, A>(ma: StateReaderTaskEither<S, R1, E, A>) => StateReaderTaskEither<S, R2, E, A>
  151. /**
  152. * Less strict version of [`asksStateReaderTaskEither`](#asksstatereadertaskeither).
  153. *
  154. * @category constructors
  155. * @since 2.11.0
  156. */
  157. export declare const asksStateReaderTaskEitherW: <R1, S, R2, E, A>(
  158. f: (r1: R1) => StateReaderTaskEither<S, R2, E, A>
  159. ) => StateReaderTaskEither<S, R1 & R2, E, A>
  160. /**
  161. * Effectfully accesses the environment.
  162. *
  163. * @category constructors
  164. * @since 2.11.0
  165. */
  166. export declare const asksStateReaderTaskEither: <R, S, E, A>(
  167. f: (r: R) => StateReaderTaskEither<S, R, E, A>
  168. ) => StateReaderTaskEither<S, R, E, A>
  169. /**
  170. * @category lifting
  171. * @since 2.4.0
  172. */
  173. export declare const fromIOEitherK: <E, A extends readonly unknown[], B>(
  174. f: (...a: A) => IOEither<E, B>
  175. ) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>
  176. /**
  177. * Less strict version of [`chainIOEitherK`](#chainioeitherk).
  178. *
  179. * @category sequencing
  180. * @since 2.6.1
  181. */
  182. export declare const chainIOEitherKW: <E2, A, B>(
  183. f: (a: A) => IOEither<E2, B>
  184. ) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>
  185. /**
  186. * @category sequencing
  187. * @since 2.4.0
  188. */
  189. export declare const chainIOEitherK: <E, A, B>(
  190. f: (a: A) => IOEither<E, B>
  191. ) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  192. /**
  193. * @category lifting
  194. * @since 2.4.0
  195. */
  196. export declare const fromTaskEitherK: <E, A extends readonly unknown[], B>(
  197. f: (...a: A) => TaskEither<E, B>
  198. ) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>
  199. /**
  200. * Less strict version of [`chainTaskEitherK`](#chaintaskeitherk).
  201. *
  202. * @category sequencing
  203. * @since 2.6.1
  204. */
  205. export declare const chainTaskEitherKW: <E2, A, B>(
  206. f: (a: A) => TaskEither<E2, B>
  207. ) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>
  208. /**
  209. * @category sequencing
  210. * @since 2.4.0
  211. */
  212. export declare const chainTaskEitherK: <E, A, B>(
  213. f: (a: A) => TaskEither<E, B>
  214. ) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  215. /**
  216. * @category lifting
  217. * @since 2.4.0
  218. */
  219. export declare const fromReaderTaskEitherK: <R, E, A extends readonly unknown[], B>(
  220. f: (...a: A) => RTE.ReaderTaskEither<R, E, B>
  221. ) => <S>(...a: A) => StateReaderTaskEither<S, R, E, B>
  222. /**
  223. * Less strict version of [`chainReaderTaskEitherK`](#chainreadertaskeitherk).
  224. *
  225. * @category sequencing
  226. * @since 2.6.1
  227. */
  228. export declare const chainReaderTaskEitherKW: <R, E2, A, B>(
  229. f: (a: A) => RTE.ReaderTaskEither<R, E2, B>
  230. ) => <S, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>
  231. /**
  232. * @category sequencing
  233. * @since 2.4.0
  234. */
  235. export declare const chainReaderTaskEitherK: <R, E, A, B>(
  236. f: (a: A) => ReaderTaskEither<R, E, B>
  237. ) => <S>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  238. /**
  239. * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
  240. * use the type constructor `F` to represent some computational context.
  241. *
  242. * @category mapping
  243. * @since 2.0.0
  244. */
  245. export declare const map: <A, B>(
  246. f: (a: A) => B
  247. ) => <S, R, E>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  248. /**
  249. * Map a pair of functions over the two last type arguments of the bifunctor.
  250. *
  251. * @category mapping
  252. * @since 2.6.2
  253. */
  254. export declare const bimap: <E, G, A, B>(
  255. f: (e: E) => G,
  256. g: (a: A) => B
  257. ) => <S, R>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, G, B>
  258. /**
  259. * Map a function over the third type argument of a bifunctor.
  260. *
  261. * @category error handling
  262. * @since 2.6.2
  263. */
  264. export declare const mapLeft: <E, G>(
  265. f: (e: E) => G
  266. ) => <S, R, A>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, G, A>
  267. /**
  268. * @since 2.0.0
  269. */
  270. export declare const ap: <S, R, E, A>(
  271. fa: StateReaderTaskEither<S, R, E, A>
  272. ) => <B>(fab: StateReaderTaskEither<S, R, E, (a: A) => B>) => StateReaderTaskEither<S, R, E, B>
  273. /**
  274. * Less strict version of [`ap`](#ap).
  275. *
  276. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  277. *
  278. * @since 2.8.0
  279. */
  280. export declare const apW: <S, R2, E2, A>(
  281. fa: StateReaderTaskEither<S, R2, E2, A>
  282. ) => <R1, E1, B>(fab: StateReaderTaskEither<S, R1, E1, (a: A) => B>) => StateReaderTaskEither<S, R1 & R2, E1 | E2, B>
  283. /**
  284. * @category constructors
  285. * @since 2.7.0
  286. */
  287. export declare const of: <S, R = unknown, E = never, A = never>(a: A) => StateReaderTaskEither<S, R, E, A>
  288. /**
  289. * Composes computations in sequence, using the return value of one computation to determine the next computation.
  290. *
  291. * @category sequencing
  292. * @since 2.0.0
  293. */
  294. export declare const chain: <S, R, E, A, B>(
  295. f: (a: A) => StateReaderTaskEither<S, R, E, B>
  296. ) => (ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  297. /**
  298. * Less strict version of [`chain`](#chain).
  299. *
  300. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  301. *
  302. * @category sequencing
  303. * @since 2.6.0
  304. */
  305. export declare const chainW: <S, R2, E2, A, B>(
  306. f: (a: A) => StateReaderTaskEither<S, R2, E2, B>
  307. ) => <R1, E1>(ma: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E1 | E2, B>
  308. /**
  309. * Less strict version of [`flatten`](#flatten).
  310. *
  311. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  312. *
  313. * @category sequencing
  314. * @since 2.11.0
  315. */
  316. export declare const flattenW: <S, R1, E1, R2, E2, A>(
  317. mma: StateReaderTaskEither<S, R1, E1, StateReaderTaskEither<S, R2, E2, A>>
  318. ) => StateReaderTaskEither<S, R1 & R2, E1 | E2, A>
  319. /**
  320. * @category sequencing
  321. * @since 2.0.0
  322. */
  323. export declare const flatten: <S, R, E, A>(
  324. mma: StateReaderTaskEither<S, R, E, StateReaderTaskEither<S, R, E, A>>
  325. ) => StateReaderTaskEither<S, R, E, A>
  326. /**
  327. * Less strict version of [`alt`](#alt).
  328. *
  329. * The `W` suffix (short for **W**idening) means that the environment, the error and the return types will be merged.
  330. *
  331. * @category error handling
  332. * @since 2.9.0
  333. */
  334. export declare const altW: <S, R2, E2, B>(
  335. that: () => StateReaderTaskEither<S, R2, E2, B>
  336. ) => <R1, E1, A>(fa: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2, B | A>
  337. /**
  338. * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
  339. * types of kind `* -> *`.
  340. *
  341. * @category error handling
  342. * @since 2.6.2
  343. */
  344. export declare const alt: <S, R, E, A>(
  345. that: Lazy<StateReaderTaskEither<S, R, E, A>>
  346. ) => (fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
  347. /**
  348. * @since 2.7.0
  349. */
  350. export declare const throwError: MonadThrow4<URI>['throwError']
  351. /**
  352. * @category type lambdas
  353. * @since 2.0.0
  354. */
  355. export declare const URI = 'StateReaderTaskEither'
  356. /**
  357. * @category type lambdas
  358. * @since 2.0.0
  359. */
  360. export declare type URI = typeof URI
  361. declare module './HKT' {
  362. interface URItoKind4<S, R, E, A> {
  363. readonly [URI]: StateReaderTaskEither<S, R, E, A>
  364. }
  365. }
  366. /**
  367. * @category instances
  368. * @since 2.7.0
  369. */
  370. export declare const Functor: Functor4<URI>
  371. /**
  372. * @category mapping
  373. * @since 2.10.0
  374. */
  375. export declare const flap: <A>(
  376. a: A
  377. ) => <S, R, E, B>(fab: StateReaderTaskEither<S, R, E, (a: A) => B>) => StateReaderTaskEither<S, R, E, B>
  378. /**
  379. * @category instances
  380. * @since 2.10.0
  381. */
  382. export declare const Pointed: Pointed4<URI>
  383. /**
  384. * @category instances
  385. * @since 2.10.0
  386. */
  387. export declare const Apply: Apply4<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: <S, R, E, B>(
  394. second: StateReaderTaskEither<S, R, E, B>
  395. ) => <A>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, 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: <S, R2, E2, A, B>(
  404. second: StateReaderTaskEither<S, R2, E2, B>
  405. ) => <R1, E1>(first: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, 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: <S, R, E, B>(
  412. second: StateReaderTaskEither<S, R, E, B>
  413. ) => <A>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, 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: <S, R2, E2, A, B>(
  422. second: StateReaderTaskEither<S, R2, E2, B>
  423. ) => <R1, E1>(first: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E1 | E2, B>
  424. /**
  425. * @category instances
  426. * @since 2.7.0
  427. */
  428. export declare const Applicative: Applicative4<URI>
  429. /**
  430. * @category instances
  431. * @since 2.10.0
  432. */
  433. export declare const Chain: Chain4<URI>
  434. /**
  435. * @category instances
  436. * @since 2.11.0
  437. */
  438. export declare const FromState: FromState4<URI>
  439. /**
  440. * Get the current state
  441. *
  442. * @category constructors
  443. * @since 2.0.0
  444. */
  445. export declare const get: <S, R, E = never>() => StateReaderTaskEither<S, R, E, S>
  446. /**
  447. * Set the state
  448. *
  449. * @category constructors
  450. * @since 2.0.0
  451. */
  452. export declare const put: <S, R, E = never>(s: S) => StateReaderTaskEither<S, R, E, void>
  453. /**
  454. * Modify the state by applying a function to the current state
  455. *
  456. * @category constructors
  457. * @since 2.0.0
  458. */
  459. export declare const modify: <S, R, E = never>(f: Endomorphism<S>) => StateReaderTaskEither<S, R, E, void>
  460. /**
  461. * Get a value which depends on the current state
  462. *
  463. * @category constructors
  464. * @since 2.0.0
  465. */
  466. export declare const gets: <S, R, E = never, A = never>(f: (s: S) => A) => StateReaderTaskEither<S, R, E, A>
  467. /**
  468. * @category lifting
  469. * @since 2.11.0
  470. */
  471. export declare const fromStateK: <A extends ReadonlyArray<unknown>, S, B>(
  472. f: (...a: A) => State<S, B>
  473. ) => <R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>
  474. /**
  475. * @category sequencing
  476. * @since 2.11.0
  477. */
  478. export declare const chainStateK: <A, S, B>(
  479. f: (a: A) => State<S, B>
  480. ) => <R, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  481. /**
  482. * @category instances
  483. * @since 2.10.0
  484. */
  485. export declare const Monad: Monad4<URI>
  486. /**
  487. * @category instances
  488. * @since 2.10.0
  489. */
  490. export declare const MonadIO: MonadIO4<URI>
  491. /**
  492. * @category instances
  493. * @since 2.10.0
  494. */
  495. export declare const MonadTask: MonadTask4<URI>
  496. /**
  497. * @category instances
  498. * @since 2.10.0
  499. */
  500. export declare const MonadThrow: MonadThrow4<URI>
  501. /**
  502. * Composes computations in sequence, using the return value of one computation to determine the next computation and
  503. * keeping only the result of the first.
  504. *
  505. * @category sequencing
  506. * @since 2.0.0
  507. */
  508. export declare const chainFirst: <S, R, E, A, B>(
  509. f: (a: A) => StateReaderTaskEither<S, R, E, B>
  510. ) => (ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
  511. /**
  512. * Less strict version of [`chainFirst`](#chainfirst).
  513. *
  514. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  515. *
  516. * @category sequencing
  517. * @since 2.8.0
  518. */
  519. export declare const chainFirstW: <S, R2, E2, A, B>(
  520. f: (a: A) => StateReaderTaskEither<S, R2, E2, B>
  521. ) => <R1, E1>(ma: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E1 | E2, A>
  522. /**
  523. * @category instances
  524. * @since 2.7.0
  525. */
  526. export declare const Bifunctor: Bifunctor4<URI>
  527. /**
  528. * @category instances
  529. * @since 2.7.0
  530. */
  531. export declare const Alt: Alt4<URI>
  532. /**
  533. * @category instances
  534. * @since 2.11.0
  535. */
  536. export declare const FromReader: FromReader4<URI>
  537. /**
  538. * Reads the current context.
  539. *
  540. * @category constructors
  541. * @since 2.11.0
  542. */
  543. export declare const ask: <S, R, E = never>() => StateReaderTaskEither<S, R, E, R>
  544. /**
  545. * Projects a value from the global context in a `ReaderEither`.
  546. *
  547. * @category constructors
  548. * @since 2.11.0
  549. */
  550. export declare const asks: <S, R, A, E = never>(f: (r: R) => A) => StateReaderTaskEither<S, R, E, A>
  551. /**
  552. * @category lifting
  553. * @since 2.11.0
  554. */
  555. export declare const fromReaderK: <A extends ReadonlyArray<unknown>, R, B>(
  556. f: (...a: A) => Reader<R, B>
  557. ) => <S, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>
  558. /**
  559. * @category sequencing
  560. * @since 2.11.0
  561. */
  562. export declare const chainReaderK: <A, R, B>(
  563. f: (a: A) => Reader<R, B>
  564. ) => <S, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  565. /**
  566. * Less strict version of [`chainReaderK`](#chainReaderK).
  567. *
  568. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  569. *
  570. * @category sequencing
  571. * @since 2.11.0
  572. */
  573. export declare const chainReaderKW: <A, R1, B>(
  574. f: (a: A) => Reader<R1, B>
  575. ) => <S, R2, E>(ma: StateReaderTaskEither<S, R2, E, A>) => StateReaderTaskEither<S, R1 & R2, E, B>
  576. /**
  577. * @category sequencing
  578. * @since 2.11.0
  579. */
  580. export declare const chainFirstReaderK: <A, R, B>(
  581. f: (a: A) => Reader<R, B>
  582. ) => <S, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
  583. /**
  584. * Less strict version of [`chainFirstReaderK`](#chainFirstReaderK).
  585. *
  586. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  587. *
  588. * @category sequencing
  589. * @since 2.11.0
  590. */
  591. export declare const chainFirstReaderKW: <A, R1, B>(
  592. f: (a: A) => Reader<R1, B>
  593. ) => <S, R2, E>(ma: StateReaderTaskEither<S, R2, E, A>) => StateReaderTaskEither<S, R1 & R2, E, A>
  594. /**
  595. * @category instances
  596. * @since 2.10.0
  597. */
  598. export declare const FromEither: FromEither4<URI>
  599. /**
  600. * @category conversions
  601. * @since 2.0.0
  602. */
  603. export declare const fromOption: <E>(
  604. onNone: Lazy<E>
  605. ) => <A, S, R = unknown>(fa: Option<A>) => StateReaderTaskEither<S, R, E, A>
  606. /**
  607. * @category lifting
  608. * @since 2.10.0
  609. */
  610. export declare const fromOptionK: <E>(
  611. onNone: Lazy<E>
  612. ) => <A extends ReadonlyArray<unknown>, B>(
  613. f: (...a: A) => Option<B>
  614. ) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>
  615. /**
  616. * @category sequencing
  617. * @since 2.10.0
  618. */
  619. export declare const chainOptionK: <E>(
  620. onNone: Lazy<E>
  621. ) => <A, B>(
  622. f: (a: A) => Option<B>
  623. ) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  624. /**
  625. * @category sequencing
  626. * @since 2.4.0
  627. */
  628. export declare const chainEitherK: <E, A, B>(
  629. f: (a: A) => E.Either<E, B>
  630. ) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  631. /**
  632. * Less strict version of [`chainEitherK`](#chaineitherk).
  633. *
  634. * The `W` suffix (short for **W**idening) means that the error types will be merged.
  635. *
  636. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  637. *
  638. * @category sequencing
  639. * @since 2.6.1
  640. */
  641. export declare const chainEitherKW: <E2, A, B>(
  642. f: (a: A) => Either<E2, B>
  643. ) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E1 | E2, B>
  644. /**
  645. * @category sequencing
  646. * @since 2.12.0
  647. */
  648. export declare const chainFirstEitherK: <A, E, B>(
  649. f: (a: A) => E.Either<E, B>
  650. ) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
  651. /**
  652. * Less strict version of [`chainFirstEitherK`](#chainfirsteitherk).
  653. *
  654. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  655. *
  656. * @category sequencing
  657. * @since 2.12.0
  658. */
  659. export declare const chainFirstEitherKW: <A, E2, B>(
  660. f: (a: A) => Either<E2, B>
  661. ) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E1 | E2, A>
  662. /**
  663. * @category lifting
  664. * @since 2.4.4
  665. */
  666. export declare const fromPredicate: {
  667. <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R = unknown>(
  668. a: A
  669. ) => StateReaderTaskEither<S, R, E, B>
  670. <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R = unknown, B extends A = A>(
  671. b: B
  672. ) => StateReaderTaskEither<S, R, E, B>
  673. <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R = unknown>(a: A) => StateReaderTaskEither<S, R, E, A>
  674. }
  675. /**
  676. * @category filtering
  677. * @since 2.4.4
  678. */
  679. export declare const filterOrElse: {
  680. <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(
  681. ma: StateReaderTaskEither<S, R, E, A>
  682. ) => StateReaderTaskEither<S, R, E, B>
  683. <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R, B extends A>(
  684. mb: StateReaderTaskEither<S, R, E, B>
  685. ) => StateReaderTaskEither<S, R, E, B>
  686. <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(
  687. ma: StateReaderTaskEither<S, R, E, A>
  688. ) => StateReaderTaskEither<S, R, E, A>
  689. }
  690. /**
  691. * Less strict version of [`filterOrElse`](#filterorelse).
  692. *
  693. * The `W` suffix (short for **W**idening) means that the error types will be merged.
  694. *
  695. * @category filtering
  696. * @since 2.9.0
  697. */
  698. export declare const filterOrElseW: {
  699. <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <S, R, E1>(
  700. ma: StateReaderTaskEither<S, R, E1, A>
  701. ) => StateReaderTaskEither<S, R, E1 | E2, B>
  702. <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <S, R, E1, B extends A>(
  703. mb: StateReaderTaskEither<S, R, E1, B>
  704. ) => StateReaderTaskEither<S, R, E1 | E2, B>
  705. <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <S, R, E1>(
  706. ma: StateReaderTaskEither<S, R, E1, A>
  707. ) => StateReaderTaskEither<S, R, E1 | E2, A>
  708. }
  709. /**
  710. * @category lifting
  711. * @since 2.4.0
  712. */
  713. export declare const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(
  714. f: (...a: A) => E.Either<E, B>
  715. ) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>
  716. /**
  717. * @category instances
  718. * @since 2.10.0
  719. */
  720. export declare const FromIO: FromIO4<URI>
  721. /**
  722. * @category lifting
  723. * @since 2.10.0
  724. */
  725. export declare const fromIOK: <A extends ReadonlyArray<unknown>, B>(
  726. f: (...a: A) => IO<B>
  727. ) => <S, R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>
  728. /**
  729. * @category sequencing
  730. * @since 2.10.0
  731. */
  732. export declare const chainIOK: <A, B>(
  733. f: (a: A) => IO<B>
  734. ) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  735. /**
  736. * @category sequencing
  737. * @since 2.10.0
  738. */
  739. export declare const chainFirstIOK: <A, B>(
  740. f: (a: A) => IO<B>
  741. ) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
  742. /**
  743. * @category instances
  744. * @since 2.10.0
  745. */
  746. export declare const FromTask: FromTask4<URI>
  747. /**
  748. * @category lifting
  749. * @since 2.10.0
  750. */
  751. export declare const fromTaskK: <A extends ReadonlyArray<unknown>, B>(
  752. f: (...a: A) => Task<B>
  753. ) => <S, R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>
  754. /**
  755. * @category sequencing
  756. * @since 2.10.0
  757. */
  758. export declare const chainTaskK: <A, B>(
  759. f: (a: A) => Task<B>
  760. ) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>
  761. /**
  762. * @category sequencing
  763. * @since 2.10.0
  764. */
  765. export declare const chainFirstTaskK: <A, B>(
  766. f: (a: A) => Task<B>
  767. ) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>
  768. /**
  769. * Run a computation in the `StateReaderTaskEither` monad, discarding the final state
  770. *
  771. * @since 2.8.0
  772. */
  773. export declare const evaluate: <S>(
  774. s: S
  775. ) => <R, E, A>(ma: StateReaderTaskEither<S, R, E, A>) => ReaderTaskEither<R, E, A>
  776. /**
  777. * Run a computation in the `StateReaderTaskEither` monad discarding the result
  778. *
  779. * @since 2.8.0
  780. */
  781. export declare const execute: <S>(s: S) => <R, E, A>(ma: StateReaderTaskEither<S, R, E, A>) => ReaderTaskEither<R, E, S>
  782. /**
  783. * @since 2.8.0
  784. */
  785. export declare const bindTo: <N extends string>(
  786. name: N
  787. ) => <S, R, E, A>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, { readonly [K in N]: A }>
  788. declare const let_: <N extends string, A, B>(
  789. name: Exclude<N, keyof A>,
  790. f: (a: A) => B
  791. ) => <S, R, E>(
  792. fa: StateReaderTaskEither<S, R, E, A>
  793. ) => StateReaderTaskEither<S, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
  794. export {
  795. /**
  796. * @since 2.13.0
  797. */
  798. let_ as let
  799. }
  800. /**
  801. * @since 2.8.0
  802. */
  803. export declare const bind: <N extends string, A, S, R, E, B>(
  804. name: Exclude<N, keyof A>,
  805. f: (a: A) => StateReaderTaskEither<S, R, E, B>
  806. ) => (
  807. ma: StateReaderTaskEither<S, R, E, A>
  808. ) => StateReaderTaskEither<S, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
  809. /**
  810. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  811. *
  812. * @since 2.8.0
  813. */
  814. export declare const bindW: <N extends string, A, S, R2, E2, B>(
  815. name: Exclude<N, keyof A>,
  816. f: (a: A) => StateReaderTaskEither<S, R2, E2, B>
  817. ) => <R1, E1>(
  818. fa: StateReaderTaskEither<S, R1, E1, A>
  819. ) => StateReaderTaskEither<
  820. S,
  821. R1 & R2,
  822. E1 | E2,
  823. {
  824. readonly [K in keyof A | N]: K extends keyof A ? A[K] : B
  825. }
  826. >
  827. /**
  828. * @since 2.8.0
  829. */
  830. export declare const apS: <N extends string, A, S, R, E, B>(
  831. name: Exclude<N, keyof A>,
  832. fb: StateReaderTaskEither<S, R, E, B>
  833. ) => (
  834. fa: StateReaderTaskEither<S, R, E, A>
  835. ) => StateReaderTaskEither<S, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
  836. /**
  837. * Less strict version of [`apS`](#aps).
  838. *
  839. * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
  840. *
  841. * @category do notation
  842. * @since 2.8.0
  843. */
  844. export declare const apSW: <A, N extends string, S, R2, E2, B>(
  845. name: Exclude<N, keyof A>,
  846. fb: StateReaderTaskEither<S, R2, E2, B>
  847. ) => <R1, E1>(
  848. fa: StateReaderTaskEither<S, R1, E1, A>
  849. ) => StateReaderTaskEither<
  850. S,
  851. R1 & R2,
  852. E1 | E2,
  853. {
  854. readonly [K in keyof A | N]: K extends keyof A ? A[K] : B
  855. }
  856. >
  857. /**
  858. * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.
  859. *
  860. * @category traversing
  861. * @since 2.11.0
  862. */
  863. export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, S, R, E, B>(
  864. f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>
  865. ) => (as: ReadonlyNonEmptyArray<A>) => StateReaderTaskEither<S, R, E, ReadonlyNonEmptyArray<B>>
  866. /**
  867. * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.
  868. *
  869. * @category traversing
  870. * @since 2.11.0
  871. */
  872. export declare const traverseReadonlyArrayWithIndex: <A, S, R, E, B>(
  873. f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>
  874. ) => (as: readonly A[]) => StateReaderTaskEither<S, R, E, readonly B[]>
  875. /**
  876. * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.
  877. *
  878. * @category traversing
  879. * @since 2.9.0
  880. */
  881. export declare const traverseArrayWithIndex: <S, R, E, A, B>(
  882. f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>
  883. ) => (as: ReadonlyArray<A>) => StateReaderTaskEither<S, R, E, ReadonlyArray<B>>
  884. /**
  885. * Equivalent to `ReadonlyArray#traverse(Applicative)`.
  886. *
  887. * @category traversing
  888. * @since 2.9.0
  889. */
  890. export declare const traverseArray: <S, R, E, A, B>(
  891. f: (a: A) => StateReaderTaskEither<S, R, E, B>
  892. ) => (as: readonly A[]) => StateReaderTaskEither<S, R, E, readonly B[]>
  893. /**
  894. * Equivalent to `ReadonlyArray#sequence(Applicative)`.
  895. *
  896. * @category traversing
  897. * @since 2.9.0
  898. */
  899. export declare const sequenceArray: <S, R, E, A>(
  900. arr: ReadonlyArray<StateReaderTaskEither<S, R, E, A>>
  901. ) => StateReaderTaskEither<S, R, E, ReadonlyArray<A>>
  902. /**
  903. * This instance is deprecated, use small, specific instances instead.
  904. * For example if a function needs a `Functor` instance, pass `SRTE.Functor` instead of `SRTE.stateReaderTaskEither`
  905. * (where `SRTE` is from `import SRTE from 'fp-ts/StateReaderTaskEither'`)
  906. *
  907. * @category zone of death
  908. * @since 2.0.0
  909. * @deprecated
  910. */
  911. export declare const stateReaderTaskEither: Monad4<URI> &
  912. Bifunctor4<URI> &
  913. Alt4<URI> &
  914. MonadTask4<URI> &
  915. MonadThrow4<URI>
  916. /**
  917. * This instance is deprecated, use small, specific instances instead.
  918. * For example if a function needs a `Functor` instance, pass `SRTE.Functor` instead of `SRTE.stateReaderTaskEitherSeq`
  919. * (where `SRTE` is from `import SRTE from 'fp-ts/StateReaderTaskEither'`)
  920. *
  921. * @category zone of death
  922. * @since 2.0.0
  923. * @deprecated
  924. */
  925. export declare const stateReaderTaskEitherSeq: typeof stateReaderTaskEither
  926. /**
  927. * Use [`evaluate`](#evaluate) instead
  928. *
  929. * @category zone of death
  930. * @since 2.0.0
  931. * @deprecated
  932. */
  933. export declare const evalState: <S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S) => ReaderTaskEither<R, E, A>
  934. /**
  935. * Use [`execute`](#execute) instead
  936. *
  937. * @category zone of death
  938. * @since 2.0.0
  939. * @deprecated
  940. */
  941. export declare const execState: <S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S) => ReaderTaskEither<R, E, S>
  942. /**
  943. * @category zone of death
  944. * @since 2.0.0
  945. * @deprecated
  946. */
  947. export declare function run<S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S, r: R): Promise<Either<E, [A, S]>>