UNPKG

5.82 kBTypeScriptView Raw
1/**
2 * @since 2.0.0
3 */
4import { Either } from './Either';
5import { IO } from './IO';
6import { IOEither } from './IOEither';
7import { Monad4 } from './Monad';
8import { Reader } from './Reader';
9import { ReaderEither } from './ReaderEither';
10import * as RTE from './ReaderTaskEither';
11import { State } from './State';
12import { Task } from './Task';
13import { TaskEither } from './TaskEither';
14import ReaderTaskEither = RTE.ReaderTaskEither;
15import { MonadThrow4 } from './MonadThrow';
16declare module './HKT' {
17 interface URItoKind4<S, R, E, A> {
18 StateReaderTaskEither: StateReaderTaskEither<S, R, E, A>;
19 }
20}
21/**
22 * @since 2.0.0
23 */
24export declare const URI = "StateReaderTaskEither";
25/**
26 * @since 2.0.0
27 */
28export declare type URI = typeof URI;
29/**
30 * @since 2.0.0
31 */
32export interface StateReaderTaskEither<S, R, E, A> {
33 (s: S): ReaderTaskEither<R, E, [A, S]>;
34}
35/**
36 * @since 2.0.0
37 */
38export declare function run<S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S, r: R): Promise<Either<E, [A, S]>>;
39/**
40 * Run a computation in the `StateReaderTaskEither` monad, discarding the final state
41 *
42 * @since 2.0.0
43 */
44export declare const evalState: <S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S) => ReaderTaskEither<R, E, A>;
45/**
46 * Run a computation in the `StateReaderTaskEither` monad discarding the result
47 *
48 * @since 2.0.0
49 */
50export declare const execState: <S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S) => ReaderTaskEither<R, E, S>;
51/**
52 * @since 2.0.0
53 */
54export declare function left<S, R, E = never, A = never>(e: E): StateReaderTaskEither<S, R, E, A>;
55/**
56 * @since 2.0.0
57 */
58export declare const right: <S, R, E = never, A = never>(a: A) => StateReaderTaskEither<S, R, E, A>;
59/**
60 * @since 2.0.0
61 */
62export declare function rightTask<S, R, E = never, A = never>(ma: Task<A>): StateReaderTaskEither<S, R, E, A>;
63/**
64 * @since 2.0.0
65 */
66export declare function leftTask<S, R, E = never, A = never>(me: Task<E>): StateReaderTaskEither<S, R, E, A>;
67/**
68 * @since 2.0.0
69 */
70export declare function fromTaskEither<S, R, E, A>(ma: TaskEither<E, A>): StateReaderTaskEither<S, R, E, A>;
71/**
72 * @since 2.0.0
73 */
74export declare function rightReader<S, R, E = never, A = never>(ma: Reader<R, A>): StateReaderTaskEither<S, R, E, A>;
75/**
76 * @since 2.0.0
77 */
78export declare function leftReader<S, R, E = never, A = never>(me: Reader<R, E>): StateReaderTaskEither<S, R, E, A>;
79/**
80 * @since 2.0.0
81 */
82export declare function fromIOEither<S, R, E, A>(ma: IOEither<E, A>): StateReaderTaskEither<S, R, E, A>;
83/**
84 * @since 2.0.0
85 */
86export declare function fromReaderEither<S, R, E, A>(ma: ReaderEither<R, E, A>): StateReaderTaskEither<S, R, E, A>;
87/**
88 * @since 2.0.0
89 */
90export declare function rightIO<S, R, E = never, A = never>(ma: IO<A>): StateReaderTaskEither<S, R, E, A>;
91/**
92 * @since 2.0.0
93 */
94export declare function leftIO<S, R, E = never, A = never>(me: IO<E>): StateReaderTaskEither<S, R, E, A>;
95/**
96 * @since 2.0.0
97 */
98export declare const rightState: <S, R, E = never, A = never>(ma: State<S, A>) => StateReaderTaskEither<S, R, E, A>;
99/**
100 * @since 2.0.0
101 */
102export declare function leftState<S, R, E = never, A = never>(me: State<S, E>): StateReaderTaskEither<S, R, E, A>;
103/**
104 * @since 2.0.0
105 */
106export declare const fromReaderTaskEither: <S, R, E, A>(ma: ReaderTaskEither<R, E, A>) => StateReaderTaskEither<S, R, E, A>;
107/**
108 * Get the current state
109 *
110 * @since 2.0.0
111 */
112export declare const get: <S, R, E = never>() => StateReaderTaskEither<S, R, E, S>;
113/**
114 * Set the state
115 *
116 * @since 2.0.0
117 */
118export declare const put: <S, R, E = never>(s: S) => StateReaderTaskEither<S, R, E, void>;
119/**
120 * Modify the state by applying a function to the current state
121 *
122 * @since 2.0.0
123 */
124export declare const modify: <S, R, E = never>(f: (s: S) => S) => StateReaderTaskEither<S, R, E, void>;
125/**
126 * Get a value which depends on the current state
127 *
128 * @since 2.0.0
129 */
130export declare const gets: <S, R, E = never, A = never>(f: (s: S) => A) => StateReaderTaskEither<S, R, E, A>;
131/**
132 * @since 2.0.0
133 */
134export declare const stateReaderTaskEither: Monad4<URI> & MonadThrow4<URI>;
135/**
136 * Like `stateReaderTaskEither` but `ap` is sequential
137 * @since 2.0.0
138 */
139export declare const stateReaderTaskEitherSeq: typeof stateReaderTaskEither;
140declare const ap: <S, R, E, A>(fa: StateReaderTaskEither<S, R, E, A>) => <B>(fab: StateReaderTaskEither<S, R, E, (a: A) => B>) => StateReaderTaskEither<S, R, E, B>, apFirst: <S, R, E, B>(fb: StateReaderTaskEither<S, R, E, B>) => <A>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>, apSecond: <S, R, E, B>(fb: StateReaderTaskEither<S, R, E, B>) => <A>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>, chain: <S, R, E, A, B>(f: (a: A) => StateReaderTaskEither<S, R, E, B>) => (ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>, chainFirst: <S, R, E, A, B>(f: (a: A) => StateReaderTaskEither<S, R, E, B>) => (ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>, flatten: <S, R, E, A>(mma: StateReaderTaskEither<S, R, E, StateReaderTaskEither<S, R, E, A>>) => StateReaderTaskEither<S, R, E, A>, map: <A, B>(f: (a: A) => B) => <S, R, E>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>, fromEither: <S, R, E, A>(ma: Either<E, A>) => StateReaderTaskEither<S, R, E, A>, fromOption: <E>(onNone: () => E) => <S, R, A>(ma: import("./Option").Option<A>) => StateReaderTaskEither<S, R, E, A>;
141export {
142/**
143 * @since 2.0.0
144 */
145ap,
146/**
147 * @since 2.0.0
148 */
149apFirst,
150/**
151 * @since 2.0.0
152 */
153apSecond,
154/**
155 * @since 2.0.0
156 */
157chain,
158/**
159 * @since 2.0.0
160 */
161chainFirst,
162/**
163 * @since 2.0.0
164 */
165flatten,
166/**
167 * @since 2.0.0
168 */
169map,
170/**
171 * @since 2.0.0
172 */
173fromEither,
174/**
175 * @since 2.0.0
176 */
177fromOption };