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