1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { Applicative, Applicative1, Applicative2, Applicative2C, Applicative3 } from 'fp-ts/lib/Applicative'
|
17 | import { Category2 } from 'fp-ts/lib/Category'
|
18 | import { Either } from 'fp-ts/lib/Either'
|
19 | import { Predicate, Refinement } from 'fp-ts/lib/function'
|
20 | import { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from 'fp-ts/lib/HKT'
|
21 | import { Monoid } from 'fp-ts/lib/Monoid'
|
22 | import { Option } from 'fp-ts/lib/Option'
|
23 | import { ReadonlyNonEmptyArray } from 'fp-ts/lib/ReadonlyNonEmptyArray'
|
24 | import { ReadonlyRecord } from 'fp-ts/lib/ReadonlyRecord'
|
25 | import { Semigroupoid2 } from 'fp-ts/lib/Semigroupoid'
|
26 | import { Traversable, Traversable1, Traversable2, Traversable3 } from 'fp-ts/lib/Traversable'
|
27 | import { Iso } from './Iso'
|
28 | import { Lens } from './Lens'
|
29 | import { Optional } from './Optional'
|
30 | import { Prism } from './Prism'
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | export interface ModifyF<S, A> {
|
36 | <F extends URIS3>(F: Applicative3<F>): <R, E>(f: (a: A) => Kind3<F, R, E, A>) => (s: S) => Kind3<F, R, E, S>
|
37 | <F extends URIS2>(F: Applicative2<F>): <E>(f: (a: A) => Kind2<F, E, A>) => (s: S) => Kind2<F, E, S>
|
38 | <F extends URIS2, E>(F: Applicative2C<F, E>): (f: (a: A) => Kind2<F, E, A>) => (s: S) => Kind2<F, E, S>
|
39 | <F extends URIS>(F: Applicative1<F>): (f: (a: A) => Kind<F, A>) => (s: S) => Kind<F, S>
|
40 | <F>(F: Applicative<F>): (f: (a: A) => HKT<F, A>) => (s: S) => HKT<F, S>
|
41 | }
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | export interface Traversal<S, A> {
|
47 | readonly modifyF: ModifyF<S, A>
|
48 | }
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | export declare const traversal: <S, A>(modifyF: Traversal<S, A>['modifyF']) => Traversal<S, A>
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | export declare const id: <S>() => Traversal<S, S>
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | export declare const fromTraversable: {
|
66 | <T extends URIS3>(T: Traversable3<T>): <R, E, A>() => Traversal<Kind3<T, R, E, A>, A>
|
67 | <T extends URIS2>(T: Traversable2<T>): <E, A>() => Traversal<Kind2<T, E, A>, A>
|
68 | <T extends URIS>(T: Traversable1<T>): <A>() => Traversal<Kind<T, A>, A>
|
69 | <T>(T: Traversable<T>): <A>() => Traversal<HKT<T, A>, A>
|
70 | }
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | export declare const compose: <A, B>(ab: Traversal<A, B>) => <S>(sa: Traversal<S, A>) => Traversal<S, B>
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | export declare const composeTraversal: <A, B>(ab: Traversal<A, B>) => <S>(sa: Traversal<S, A>) => Traversal<S, B>
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | export declare const composeIso: <A, B>(ab: Iso<A, B>) => <S>(sa: Traversal<S, A>) => Traversal<S, B>
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 | export declare const composeLens: <A, B>(ab: Lens<A, B>) => <S>(sa: Traversal<S, A>) => Traversal<S, B>
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | export declare const composePrism: <A, B>(ab: Prism<A, B>) => <S>(sa: Traversal<S, A>) => Traversal<S, B>
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 | export declare const composeOptional: <A, B>(ab: Optional<A, B>) => <S>(sa: Traversal<S, A>) => Traversal<S, B>
|
113 |
|
114 |
|
115 |
|
116 |
|
117 | export declare const modify: <A, B extends A = A>(f: (a: A) => B) => <S>(sa: Traversal<S, A>) => (s: S) => S
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | export declare const set: <A>(a: A) => <S>(sa: Traversal<S, A>) => (s: S) => S
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | export declare const fromNullable: <S, A>(sa: Traversal<S, A>) => Traversal<S, NonNullable<A>>
|
130 |
|
131 |
|
132 |
|
133 |
|
134 | export declare function filter<A, B extends A>(
|
135 | refinement: Refinement<A, B>
|
136 | ): <S>(sa: Traversal<S, A>) => Traversal<S, B>
|
137 | export declare function filter<A>(predicate: Predicate<A>): <S>(sa: Traversal<S, A>) => Traversal<S, A>
|
138 | /**
|
139 | * Return a `Traversal` from a `Traversal` and a prop.
|
140 | *
|
141 | * @category combinators
|
142 | * @since 2.3.0
|
143 | */
|
144 | export declare const prop: <A, P extends keyof A>(prop: P) => <S>(sa: Traversal<S, A>) => Traversal<S, A[P]>
|
145 | /**
|
146 | * Return a `Traversal` from a `Traversal` and a list of props.
|
147 | *
|
148 | * @category combinators
|
149 | * @since 2.3.0
|
150 | */
|
151 | export declare const props: <A, P extends keyof A>(
|
152 | props_0: P,
|
153 | props_1: P,
|
154 | ...props_2: P[]
|
155 | ) => <S>(sa: Traversal<S, A>) => Traversal<S, { [K in P]: A[K] }>
|
156 | /**
|
157 | * Return a `Traversal` from a `Traversal` focused on a component of a tuple.
|
158 | *
|
159 | * @category combinators
|
160 | * @since 2.3.0
|
161 | */
|
162 | export declare const component: <A extends readonly unknown[], P extends keyof A>(
|
163 | prop: P
|
164 | ) => <S>(sa: Traversal<S, A>) => Traversal<S, A[P]>
|
165 | /**
|
166 | * Return a `Traversal` from a `Traversal` focused on an index of a `ReadonlyArray`.
|
167 | *
|
168 | * @category combinators
|
169 | * @since 2.3.0
|
170 | */
|
171 | export declare const index: (i: number) => <S, A>(sa: Traversal<S, readonly A[]>) => Traversal<S, A>
|
172 | /**
|
173 | * @category combinators
|
174 | * @since 2.3.8
|
175 | */
|
176 | export declare const indexNonEmpty: (i: number) => <S, A>(sa: Traversal<S, ReadonlyNonEmptyArray<A>>) => Traversal<S, A>
|
177 | /**
|
178 | * Return a `Traversal` from a `Traversal` focused on a key of a `ReadonlyRecord`.
|
179 | *
|
180 | * @category combinators
|
181 | * @since 2.3.0
|
182 | */
|
183 | export declare const key: (key: string) => <S, A>(sa: Traversal<S, Readonly<Record<string, A>>>) => Traversal<S, A>
|
184 | /**
|
185 | * Return a `Traversal` from a `Traversal` focused on a required key of a `ReadonlyRecord`.
|
186 | *
|
187 | * @category combinators
|
188 | * @since 2.3.0
|
189 | */
|
190 | export declare const atKey: (
|
191 | key: string
|
192 | ) => <S, A>(sa: Traversal<S, Readonly<Record<string, A>>>) => Traversal<S, Option<A>>
|
193 | /**
|
194 | * Return a `Traversal` from a `Traversal` focused on the `Some` of a `Option` type.
|
195 | *
|
196 | * @category combinators
|
197 | * @since 2.3.0
|
198 | */
|
199 | export declare const some: <S, A>(soa: Traversal<S, Option<A>>) => Traversal<S, A>
|
200 | /**
|
201 | * Return a `Traversal` from a `Traversal` focused on the `Right` of a `Either` type.
|
202 | *
|
203 | * @category combinators
|
204 | * @since 2.3.0
|
205 | */
|
206 | export declare const right: <S, E, A>(sea: Traversal<S, Either<E, A>>) => Traversal<S, A>
|
207 | /**
|
208 | * Return a `Traversal` from a `Traversal` focused on the `Left` of a `Either` type.
|
209 | *
|
210 | * @category combinators
|
211 | * @since 2.3.0
|
212 | */
|
213 | export declare const left: <S, E, A>(sea: Traversal<S, Either<E, A>>) => Traversal<S, E>
|
214 | /**
|
215 | * Return a `Traversal` from a `Traversal` focused on a `Traversable`.
|
216 | *
|
217 | * @category combinators
|
218 | * @since 2.3.0
|
219 | */
|
220 | export declare const traverse: <T extends URIS>(
|
221 | T: Traversable1<T>
|
222 | ) => <S, A>(sta: Traversal<S, Kind<T, A>>) => Traversal<S, A>
|
223 | /**
|
224 | * @category combinators
|
225 | * @since 2.3.8
|
226 | */
|
227 | export declare function findFirst<A, B extends A>(
|
228 | refinement: Refinement<A, B>
|
229 | ): <S>(sa: Traversal<S, ReadonlyArray<A>>) => Traversal<S, B>
|
230 | export declare function findFirst<A>(
|
231 | predicate: Predicate<A>
|
232 | ): <S>(sa: Traversal<S, ReadonlyArray<A>>) => Traversal<S, A>
|
233 | /**
|
234 | * @category combinators
|
235 | * @since 2.3.8
|
236 | */
|
237 | export declare function findFirstNonEmpty<A, B extends A>(
|
238 | refinement: Refinement<A, B>
|
239 | ): <S>(sa: Traversal<S, ReadonlyNonEmptyArray<A>>) => Traversal<S, B>
|
240 | export declare function findFirstNonEmpty<A>(
|
241 | predicate: Predicate<A>
|
242 | ): <S>(sa: Traversal<S, ReadonlyNonEmptyArray<A>>) => Traversal<S, A>
|
243 | /**
|
244 | * Map each target to a `Monoid` and combine the results.
|
245 | *
|
246 | * @category combinators
|
247 | * @since 2.3.0
|
248 | */
|
249 | export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <S>(sa: Traversal<S, A>) => (s: S) => M
|
250 | /**
|
251 | * Map each target to a `Monoid` and combine the results.
|
252 | *
|
253 | * @category combinators
|
254 | * @since 2.3.0
|
255 | */
|
256 | export declare const fold: <A>(M: Monoid<A>) => <S>(sa: Traversal<S, A>) => (s: S) => A
|
257 | /**
|
258 | * Get all the targets of a `Traversal`.
|
259 | *
|
260 | * @category combinators
|
261 | * @since 2.3.0
|
262 | */
|
263 | export declare const getAll: <S>(s: S) => <A>(sa: Traversal<S, A>) => readonly A[]
|
264 | /**
|
265 | * @category instances
|
266 | * @since 2.3.0
|
267 | */
|
268 | export declare const URI = 'monocle-ts/Traversal'
|
269 | /**
|
270 | * @category instances
|
271 | * @since 2.3.0
|
272 | */
|
273 | export declare type URI = typeof URI
|
274 | declare module 'fp-ts/lib/HKT' {
|
275 | interface URItoKind2<E, A> {
|
276 | readonly [URI]: Traversal<E, A>
|
277 | }
|
278 | }
|
279 | /**
|
280 | * @category instances
|
281 | * @since 2.3.8
|
282 | */
|
283 | export declare const Semigroupoid: Semigroupoid2<URI>
|
284 | /**
|
285 | * @category instances
|
286 | * @since 2.3.0
|
287 | */
|
288 | export declare const Category: Category2<URI>
|
289 |
|
\ | No newline at end of file |