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