UNPKG

2.19 kBTypeScriptView Raw
1/**
2 * **This module is experimental**
3 *
4 * Experimental features are published in order to get early feedback from the community.
5 *
6 * A feature tagged as _Experimental_ is in a high state of flux, you're at risk of it changing without notice.
7 *
8 * @since 2.3.0
9 */
10import * as O from 'fp-ts/lib/Option'
11import { At } from './At'
12import { Iso } from './Iso'
13import { Optional } from './Optional'
14import { Eq } from 'fp-ts/lib/Eq'
15import Option = O.Option
16import { ReadonlyRecord } from 'fp-ts/lib/ReadonlyRecord'
17import { ReadonlyNonEmptyArray } from 'fp-ts/lib/ReadonlyNonEmptyArray'
18/**
19 * @category model
20 * @since 2.3.0
21 */
22export interface Index<S, I, A> {
23 readonly index: (i: I) => Optional<S, A>
24}
25/**
26 * @category constructors
27 * @since 2.3.8
28 */
29export declare const index: <S, I, A>(index: Index<S, I, A>['index']) => Index<S, I, A>
30/**
31 * @category constructors
32 * @since 2.3.0
33 */
34export declare const fromAt: <T, J, B>(at: At<T, J, O.Option<B>>) => Index<T, J, B>
35/**
36 * Lift an instance of `Index` using an `Iso`.
37 *
38 * @category constructors
39 * @since 2.3.0
40 */
41export declare const fromIso: <T, S>(iso: Iso<T, S>) => <I, A>(sia: Index<S, I, A>) => Index<T, I, A>
42/**
43 * @category constructors
44 * @since 2.3.7
45 */
46export declare const indexReadonlyArray: <A = never>() => Index<ReadonlyArray<A>, number, A>
47/**
48 * @category constructors
49 * @since 2.3.8
50 */
51export declare const indexReadonlyNonEmptyArray: <A = never>() => Index<ReadonlyNonEmptyArray<A>, number, A>
52/**
53 * @category constructors
54 * @since 2.3.7
55 */
56export declare const indexReadonlyRecord: <A = never>() => Index<ReadonlyRecord<string, A>, string, A>
57/**
58 * @category constructors
59 * @since 2.3.7
60 */
61export declare const indexReadonlyMap: <K>(E: Eq<K>) => <A = never>() => Index<ReadonlyMap<K, A>, K, A>
62/**
63 * Use `indexReadonlyArray` instead.
64 *
65 * @category constructors
66 * @since 2.3.2
67 * @deprecated
68 */
69export declare const indexArray: <A = never>() => Index<ReadonlyArray<A>, number, A>
70/**
71 * Use `indexReadonlyRecord` instead.
72 *
73 * @category constructors
74 * @since 2.3.2
75 * @deprecated
76 */
77export declare const indexRecord: <A = never>() => Index<ReadonlyRecord<string, A>, string, A>