版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 1 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. import { Compactable2 } from './Compactable'
  2. import { Either } from './Either'
  3. import { Eq } from './Eq'
  4. import { Filterable2 } from './Filterable'
  5. import { FilterableWithIndex2C } from './FilterableWithIndex'
  6. import { Foldable, Foldable1, Foldable2, Foldable2C, Foldable3 } from './Foldable'
  7. import { FoldableWithIndex2C } from './FoldableWithIndex'
  8. import { Functor2 } from './Functor'
  9. import { FunctorWithIndex2C } from './FunctorWithIndex'
  10. import { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'
  11. import { Magma } from './Magma'
  12. import { Monoid } from './Monoid'
  13. import * as O from './Option'
  14. import { Ord } from './Ord'
  15. import { Predicate } from './Predicate'
  16. import { Refinement } from './Refinement'
  17. import { Semigroup } from './Semigroup'
  18. import { Separated } from './Separated'
  19. import { Show } from './Show'
  20. import { Traversable2C } from './Traversable'
  21. import { TraversableWithIndex2C } from './TraversableWithIndex'
  22. import { Unfoldable, Unfoldable1 } from './Unfoldable'
  23. import { Witherable2C } from './Witherable'
  24. import Option = O.Option
  25. /**
  26. * @category conversions
  27. * @since 2.5.0
  28. */
  29. export declare const fromMap: <K, A>(m: Map<K, A>) => ReadonlyMap<K, A>
  30. /**
  31. * @category conversions
  32. * @since 2.5.0
  33. */
  34. export declare function toMap<K, A>(m: ReadonlyMap<K, A>): Map<K, A>
  35. /**
  36. * @category instances
  37. * @since 2.5.0
  38. */
  39. export declare function getShow<K, A>(SK: Show<K>, SA: Show<A>): Show<ReadonlyMap<K, A>>
  40. /**
  41. * Calculate the number of key/value pairs in a map
  42. *
  43. * @since 2.5.0
  44. */
  45. export declare const size: <K, A>(m: ReadonlyMap<K, A>) => number
  46. /**
  47. * Test whether or not a map is empty
  48. *
  49. * @since 2.5.0
  50. */
  51. export declare const isEmpty: <K, A>(m: ReadonlyMap<K, A>) => boolean
  52. /**
  53. * Test whether or not a key exists in a map
  54. *
  55. * @since 2.5.0
  56. */
  57. export declare function member<K>(E: Eq<K>): {
  58. (k: K): <A>(m: ReadonlyMap<K, A>) => boolean
  59. <A>(k: K, m: ReadonlyMap<K, A>): boolean
  60. }
  61. /**
  62. * Test whether or not a value is a member of a map
  63. *
  64. * @since 2.5.0
  65. */
  66. export declare function elem<A>(E: Eq<A>): {
  67. (a: A): <K>(m: ReadonlyMap<K, A>) => boolean
  68. <K>(a: A, m: ReadonlyMap<K, A>): boolean
  69. }
  70. /**
  71. * Get a sorted `ReadonlyArray` of the keys contained in a `ReadonlyMap`.
  72. *
  73. * @since 2.5.0
  74. */
  75. export declare const keys: <K>(O: Ord<K>) => <A>(m: ReadonlyMap<K, A>) => readonly K[]
  76. /**
  77. * Get a sorted `ReadonlyArray` of the values contained in a `ReadonlyMap`.
  78. *
  79. * @since 2.5.0
  80. */
  81. export declare const values: <A>(O: Ord<A>) => <K>(m: ReadonlyMap<K, A>) => readonly A[]
  82. /**
  83. * @since 2.5.0
  84. */
  85. export declare function collect<K>(
  86. O: Ord<K>
  87. ): <A, B>(f: (k: K, a: A) => B) => (m: ReadonlyMap<K, A>) => ReadonlyArray<B>
  88. /**
  89. * Get a sorted `ReadonlyArray` of the key/value pairs contained in a `ReadonlyMap`.
  90. *
  91. * @category conversions
  92. * @since 2.5.0
  93. */
  94. export declare const toReadonlyArray: <K>(O: Ord<K>) => <A>(m: ReadonlyMap<K, A>) => readonly (readonly [K, A])[]
  95. /**
  96. * Unfolds a map into a list of key/value pairs
  97. *
  98. * @category conversions
  99. * @since 2.5.0
  100. */
  101. export declare function toUnfoldable<K, F extends URIS>(
  102. ord: Ord<K>,
  103. U: Unfoldable1<F>
  104. ): <A>(d: ReadonlyMap<K, A>) => Kind<F, readonly [K, A]>
  105. export declare function toUnfoldable<K, F>(
  106. ord: Ord<K>,
  107. U: Unfoldable<F>
  108. ): <A>(d: ReadonlyMap<K, A>) => HKT<F, readonly [K, A]>
  109. /**
  110. * Insert or replace a key/value pair in a `ReadonlyMap`.
  111. *
  112. * @since 2.10.0
  113. */
  114. export declare const upsertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>
  115. /**
  116. * Delete a key and value from a map
  117. *
  118. * @since 2.5.0
  119. */
  120. export declare const deleteAt: <K>(E: Eq<K>) => (k: K) => <A>(m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>
  121. /**
  122. * @since 2.5.0
  123. */
  124. export declare const updateAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => O.Option<ReadonlyMap<K, A>>
  125. /**
  126. * @since 2.5.0
  127. */
  128. export declare const modifyAt: <K>(
  129. E: Eq<K>
  130. ) => <A>(k: K, f: (a: A) => A) => (m: ReadonlyMap<K, A>) => O.Option<ReadonlyMap<K, A>>
  131. /**
  132. * Delete a key and value from a map, returning the value as well as the subsequent map
  133. *
  134. * @since 2.5.0
  135. */
  136. export declare function pop<K>(E: Eq<K>): (k: K) => <A>(m: ReadonlyMap<K, A>) => Option<readonly [A, ReadonlyMap<K, A>]>
  137. /**
  138. * Lookup the value for a key in a `Map`.
  139. * If the result is a `Some`, the existing key is also returned.
  140. *
  141. * @since 2.5.0
  142. */
  143. export declare function lookupWithKey<K>(E: Eq<K>): {
  144. (k: K): <A>(m: ReadonlyMap<K, A>) => Option<readonly [K, A]>
  145. <A>(k: K, m: ReadonlyMap<K, A>): Option<readonly [K, A]>
  146. }
  147. /**
  148. * Lookup the value for a key in a `Map`.
  149. *
  150. * @since 2.5.0
  151. */
  152. export declare function lookup<K>(E: Eq<K>): {
  153. (k: K): <A>(m: ReadonlyMap<K, A>) => Option<A>
  154. <A>(k: K, m: ReadonlyMap<K, A>): Option<A>
  155. }
  156. /**
  157. * Test whether or not one `Map` contains all of the keys and values contained in another `Map`
  158. *
  159. * @since 2.5.0
  160. */
  161. export declare function isSubmap<K, A>(
  162. SK: Eq<K>,
  163. SA: Eq<A>
  164. ): {
  165. (that: ReadonlyMap<K, A>): (me: ReadonlyMap<K, A>) => boolean
  166. (me: ReadonlyMap<K, A>, that: ReadonlyMap<K, A>): boolean
  167. }
  168. /**
  169. * @since 2.5.0
  170. */
  171. export declare const empty: ReadonlyMap<never, never>
  172. /**
  173. * @category instances
  174. * @since 2.5.0
  175. */
  176. export declare function getEq<K, A>(SK: Eq<K>, SA: Eq<A>): Eq<ReadonlyMap<K, A>>
  177. /**
  178. * Gets `Monoid` instance for Maps given `Semigroup` instance for their values
  179. *
  180. * @category instances
  181. * @since 2.5.0
  182. */
  183. export declare function getMonoid<K, A>(SK: Eq<K>, SA: Semigroup<A>): Monoid<ReadonlyMap<K, A>>
  184. /**
  185. * Create a map with one key/value pair
  186. *
  187. * @category constructors
  188. * @since 2.5.0
  189. */
  190. export declare const singleton: <K, A>(k: K, a: A) => ReadonlyMap<K, A>
  191. /**
  192. * Create a map from a foldable collection of key/value pairs, using the
  193. * specified `Magma` to combine values for duplicate keys.
  194. *
  195. * @category constructors
  196. * @since 2.5.0
  197. */
  198. export declare function fromFoldable<F extends URIS3, K, A>(
  199. E: Eq<K>,
  200. M: Magma<A>,
  201. F: Foldable3<F>
  202. ): <R, E>(fka: Kind3<F, R, E, readonly [K, A]>) => ReadonlyMap<K, A>
  203. export declare function fromFoldable<F extends URIS2, K, A>(
  204. E: Eq<K>,
  205. M: Magma<A>,
  206. F: Foldable2<F>
  207. ): <E>(fka: Kind2<F, E, readonly [K, A]>) => ReadonlyMap<K, A>
  208. export declare function fromFoldable<F extends URIS, K, A>(
  209. E: Eq<K>,
  210. M: Magma<A>,
  211. F: Foldable1<F>
  212. ): (fka: Kind<F, readonly [K, A]>) => ReadonlyMap<K, A>
  213. export declare function fromFoldable<F, K, A>(
  214. E: Eq<K>,
  215. M: Magma<A>,
  216. F: Foldable<F>
  217. ): (fka: HKT<F, readonly [K, A]>) => ReadonlyMap<K, A>
  218. /**
  219. * @since 2.10.0
  220. */
  221. export declare const partitionMapWithIndex: <K, A, B, C>(
  222. f: (k: K, a: A) => Either<B, C>
  223. ) => (fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, C>>
  224. /**
  225. * @since 2.10.0
  226. */
  227. export declare function partitionWithIndex<K, A, B extends A>(
  228. predicateWithIndex: (k: K, a: A) => a is B
  229. ): (m: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>
  230. export declare function partitionWithIndex<K, A>(
  231. predicateWithIndex: (k: K, a: A) => boolean
  232. ): <B extends A>(m: ReadonlyMap<K, B>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, B>>
  233. export declare function partitionWithIndex<K, A>(
  234. predicateWithIndex: (k: K, a: A) => boolean
  235. ): (m: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>>
  236. /**
  237. * @since 2.10.0
  238. */
  239. export declare const filterMapWithIndex: <K, A, B>(
  240. f: (k: K, a: A) => O.Option<B>
  241. ) => (fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>
  242. /**
  243. * @since 2.10.0
  244. */
  245. export declare function filterWithIndex<K, A, B extends A>(
  246. predicateWithIndex: (k: K, a: A) => a is B
  247. ): (m: ReadonlyMap<K, A>) => ReadonlyMap<K, B>
  248. export declare function filterWithIndex<K, A>(
  249. predicateWithIndex: (k: K, a: A) => boolean
  250. ): <B extends A>(m: ReadonlyMap<K, B>) => ReadonlyMap<K, B>
  251. export declare function filterWithIndex<K, A>(
  252. predicateWithIndex: (k: K, a: A) => boolean
  253. ): (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>
  254. /**
  255. * @category filtering
  256. * @since 2.5.0
  257. */
  258. export declare const compact: <K, A>(fa: ReadonlyMap<K, O.Option<A>>) => ReadonlyMap<K, A>
  259. /**
  260. * @category filtering
  261. * @since 2.5.0
  262. */
  263. export declare const filter: {
  264. <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>
  265. <A>(predicate: Predicate<A>): <K, B extends A>(fb: ReadonlyMap<K, B>) => ReadonlyMap<K, B>
  266. <A>(predicate: Predicate<A>): <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, A>
  267. }
  268. /**
  269. * @category filtering
  270. * @since 2.5.0
  271. */
  272. export declare const filterMap: <A, B>(f: (a: A) => Option<B>) => <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>
  273. /**
  274. * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
  275. * use the type constructor `F` to represent some computational context.
  276. *
  277. * @category mapping
  278. * @since 2.5.0
  279. */
  280. export declare const map: <A, B>(f: (a: A) => B) => <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>
  281. /**
  282. * @category mapping
  283. * @since 2.7.1
  284. */
  285. export declare const mapWithIndex: <K, A, B>(f: (k: K, a: A) => B) => (fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>
  286. /**
  287. * @category filtering
  288. * @since 2.5.0
  289. */
  290. export declare const partition: {
  291. <A, B extends A>(refinement: Refinement<A, B>): <K>(
  292. fa: ReadonlyMap<K, A>
  293. ) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>
  294. <A>(predicate: Predicate<A>): <K, B extends A>(
  295. fb: ReadonlyMap<K, B>
  296. ) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, B>>
  297. <A>(predicate: Predicate<A>): <K>(fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>>
  298. }
  299. /**
  300. * @category filtering
  301. * @since 2.5.0
  302. */
  303. export declare const partitionMap: <A, B, C>(
  304. f: (a: A) => Either<B, C>
  305. ) => <K>(fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, C>>
  306. /**
  307. * @category filtering
  308. * @since 2.5.0
  309. */
  310. export declare const separate: <K, A, B>(
  311. fa: ReadonlyMap<K, Either<A, B>>
  312. ) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>
  313. /**
  314. * @category type lambdas
  315. * @since 2.5.0
  316. */
  317. export declare const URI = 'ReadonlyMap'
  318. /**
  319. * @category type lambdas
  320. * @since 2.5.0
  321. */
  322. export declare type URI = typeof URI
  323. declare module './HKT' {
  324. interface URItoKind2<E, A> {
  325. readonly [URI]: ReadonlyMap<E, A>
  326. }
  327. }
  328. /**
  329. * @category instances
  330. * @since 2.11.0
  331. */
  332. export declare const getUnionSemigroup: <K, A>(E: Eq<K>, S: Semigroup<A>) => Semigroup<ReadonlyMap<K, A>>
  333. /**
  334. * @category instances
  335. * @since 2.11.0
  336. */
  337. export declare const getUnionMonoid: <K, A>(E: Eq<K>, S: Semigroup<A>) => Monoid<ReadonlyMap<K, A>>
  338. /**
  339. * @category instances
  340. * @since 2.11.0
  341. */
  342. export declare const getIntersectionSemigroup: <K, A>(E: Eq<K>, S: Semigroup<A>) => Semigroup<ReadonlyMap<K, A>>
  343. /**
  344. * @category instances
  345. * @since 2.11.0
  346. */
  347. export declare const getDifferenceMagma: <K>(E: Eq<K>) => <A>() => Magma<ReadonlyMap<K, A>>
  348. /**
  349. * @category filtering
  350. * @since 2.5.0
  351. */
  352. export declare function getFilterableWithIndex<K = never>(): FilterableWithIndex2C<URI, K, K>
  353. /**
  354. * @category instances
  355. * @since 2.7.0
  356. */
  357. export declare const Functor: Functor2<URI>
  358. /**
  359. * @category mapping
  360. * @since 2.10.0
  361. */
  362. export declare const flap: <A>(a: A) => <E, B>(fab: ReadonlyMap<E, (a: A) => B>) => ReadonlyMap<E, B>
  363. /**
  364. * @category instances
  365. * @since 2.10.0
  366. */
  367. export declare const getFunctorWithIndex: <K = never>() => FunctorWithIndex2C<'ReadonlyMap', K, K>
  368. /**
  369. * @category instances
  370. * @since 2.7.0
  371. */
  372. export declare const Compactable: Compactable2<URI>
  373. /**
  374. * @category instances
  375. * @since 2.7.0
  376. */
  377. export declare const Filterable: Filterable2<URI>
  378. /**
  379. * @category folding
  380. * @since 2.11.0
  381. */
  382. export declare const reduce: <K>(O: Ord<K>) => <B, A>(b: B, f: (b: B, a: A) => B) => (m: ReadonlyMap<K, A>) => B
  383. /**
  384. * @category folding
  385. * @since 2.11.0
  386. */
  387. export declare const foldMap: <K>(O: Ord<K>) => <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (m: ReadonlyMap<K, A>) => M
  388. /**
  389. * @category folding
  390. * @since 2.11.0
  391. */
  392. export declare const reduceRight: <K>(O: Ord<K>) => <B, A>(b: B, f: (a: A, b: B) => B) => (m: ReadonlyMap<K, A>) => B
  393. /**
  394. * @category folding
  395. * @since 2.10.0
  396. */
  397. export declare const getFoldable: <K>(O: Ord<K>) => Foldable2C<'ReadonlyMap', K>
  398. /**
  399. * @category folding
  400. * @since 2.11.0
  401. */
  402. export declare const reduceWithIndex: <K>(
  403. O: Ord<K>
  404. ) => <B, A>(b: B, f: (k: K, b: B, a: A) => B) => (m: ReadonlyMap<K, A>) => B
  405. /**
  406. * @category folding
  407. * @since 2.11.0
  408. */
  409. export declare const foldMapWithIndex: <K>(
  410. O: Ord<K>
  411. ) => <M>(M: Monoid<M>) => <A>(f: (k: K, a: A) => M) => (m: ReadonlyMap<K, A>) => M
  412. /**
  413. * @category folding
  414. * @since 2.11.0
  415. */
  416. export declare const reduceRightWithIndex: <K>(
  417. O: Ord<K>
  418. ) => <B, A>(b: B, f: (k: K, a: A, b: B) => B) => (m: ReadonlyMap<K, A>) => B
  419. /**
  420. * @category folding
  421. * @since 2.10.0
  422. */
  423. export declare const getFoldableWithIndex: <K>(O: Ord<K>) => FoldableWithIndex2C<'ReadonlyMap', K, K>
  424. /**
  425. * @category traversing
  426. * @since 2.10.0
  427. */
  428. export declare const getTraversable: <K>(O: Ord<K>) => Traversable2C<'ReadonlyMap', K>
  429. /**
  430. * @category traversing
  431. * @since 2.10.0
  432. */
  433. export declare const getTraversableWithIndex: <K>(O: Ord<K>) => TraversableWithIndex2C<'ReadonlyMap', K, K>
  434. /**
  435. * @category filtering
  436. * @since 2.5.0
  437. */
  438. export declare function getWitherable<K>(O: Ord<K>): Witherable2C<URI, K> & TraversableWithIndex2C<URI, K, K>
  439. /**
  440. * @since 2.11.0
  441. */
  442. export declare const union: <K, A>(
  443. E: Eq<K>,
  444. M: Magma<A>
  445. ) => (second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>
  446. /**
  447. * @since 2.11.0
  448. */
  449. export declare const intersection: <K, A>(
  450. E: Eq<K>,
  451. M: Magma<A>
  452. ) => (second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>
  453. /**
  454. * @since 2.11.0
  455. */
  456. export declare const difference: <K>(
  457. E: Eq<K>
  458. ) => <A>(_second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>
  459. /**
  460. * Use [`upsertAt`](#upsertat) instead.
  461. *
  462. @category zone of death
  463. * @since 2.5.0
  464. * @deprecated
  465. */
  466. export declare const insertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>
  467. /**
  468. * This instance is deprecated, use small, specific instances instead.
  469. * For example if a function needs a `Functor` instance, pass `RM.Functor` instead of `RM.readonlyMap`
  470. * (where `RM` is from `import RM from 'fp-ts/ReadonlyMap'`)
  471. *
  472. * @category zone of death
  473. * @since 2.5.0
  474. * @deprecated
  475. */
  476. export declare const readonlyMap: Filterable2<URI>