Constraint ImmMap keys to arraykey
[hiphop-php.git] / hphp / hack / hhi / rx / interfaces.hhi
blob681f61113e54727922092ba696508030426af149
1 <?hh // partial
2 /**
3  * Copyright (c) 2014, Facebook, Inc.
4  * All rights reserved.
5  *
6  * This source code is licensed under the MIT license found in the
7  * LICENSE file in the "hack" directory of this source tree.
8  *
9  */
11 /**
12  * This file provides type information for some of hack's reactive interfaces
13  *
14  * YOU SHOULD NEVER INCLUDE THIS FILE ANYWHERE!!!
15  */
17 namespace HH\Rx;
19 /* See documentation for \Traversable */
20 <<__Sealed(
21   namespace\KeyedTraversable::class,
22   namespace\Iterator::class,
23   namespace\IteratorAggregate::class,
24   \Container::class
25 )>>
26 interface Traversable<+Tv> extends \Traversable<Tv> {}
28 /* See documentation for \KeyedTraversable */
29 <<__Sealed(
30   namespace\KeyedIterable::class,
31   namespace\KeyedIterator::class,
32   \KeyedContainer::class
33 )>>
34 interface KeyedTraversable<+Tk, +Tv>
35   extends namespace\Traversable<Tv>, \KeyedTraversable<Tk, Tv> {}
37 /* See documentation for \Iterator */
38 interface Iterator<+Tv> extends namespace\Traversable<Tv>, \Iterator<Tv> {
39   /**
40    * Return the current value at the current iterator position.
41    *
42    * @return - The current value of type `Tv`.
43    */
44   <<__Rx, __MaybeMutable>>
45   public function current(): Tv;
46   /**
47    * Move the iterator position to the next element.
48    *
49    */
50   <<__Rx, __Mutable>>
51   public function next(): void;
52   /**
53    * Rewind the iterator position to its beginning.
54    *
55    * This rewinds back to the first element of the `Iterator`.
56    */
57   <<__Rx, __Mutable>>
58   public function rewind(): void;
59   /**
60    * Checks to see if the current iterator position is valid.
61    *
62    * This method is called after `rewind()` and `next()` to check if the
63    * current iterator position is valid.
64    *
65    * @return - `true` if the position is valid; `false` otherwise.
66    */
67   <<__Rx, __MaybeMutable>>
68   public function valid(): bool;
71 interface KeyedIterator<+Tk, +Tv>
72   extends
73     namespace\KeyedTraversable<Tk, Tv>,
74     namespace\Iterator<Tv>,
75     \KeyedIterator<Tk, Tv> {
76   /**
77    * Return the current key at the current iterator position.
78    *
79    * @return - The current key of type `Tk`.
80    */
81   <<__Rx, __MaybeMutable>>
82   public function key(): Tk;
85 /* See documentation for \AsyncIterator */
86 interface AsyncIterator<+Tv> extends \AsyncIterator<Tv> {
87   /**
88    * Move the async iterator to the next `Awaitable` position.
89    *
90    * ```
91    * foreach ($async_iter await $async_iter->next() $value)
92    * ```
93    *
94    * The above is the longhand syntax for `await as $value`.
95    *
96    * @return - The next `Awaitable` in the iterator sequence.
97    */
98   <<__Rx, __Mutable>>
99   public function next(): Awaitable<?(mixed, Tv)>;
102 /* See documentation for \AsyncKeyedIterator */
103 interface AsyncKeyedIterator<+Tk, +Tv>
104   extends namespace\AsyncIterator<Tv>, \AsyncKeyedIterator<Tk, Tv> {
105   /**
106    * Move the async iterator to the next `Awaitable` position.
107    *
108    * ```
109    * foreach ($async_iter await $async_iter->next() $key=>$value)
110    * ```
111    *
112    * The above is the longhand syntax for `await as $key=>$value`.
113    *
114    * @return - The next `Awaitable` in the iterator sequence.
115    */
116   <<__Rx, __Mutable>>
117   public function next(): Awaitable<?(Tk, Tv)>;
120 /* See documentation for \IteratorAggregate */
121 interface IteratorAggregate<+Tv>
122   extends namespace\Traversable<Tv>, \IteratorAggregate<Tv> {
123   /**
124    * Returns an iterator to be used to iterate over the object's elements.
125    *
126    * @return - An `Iterator` for iteration.
127    */
128   <<__Rx, __MutableReturn, __MaybeMutable>>
129   public function getIterator(): namespace\Iterator<Tv>;
132 interface Iterable<+Tv>
133   extends namespace\IteratorAggregate<Tv>, \Iterable<Tv> {
134   /**
135    * Returns an iterator that points to beginning of the current `Iterable`.
136    *
137    * @return - An `Iterator` that allows you to traverse the current `Iterable`.
138    */
139   <<__Rx, __MutableReturn, __MaybeMutable>>
140   public function getIterator(): namespace\Iterator<Tv>;
141   /**
142    * Returns an `array` converted from the current `Iterable`.
143    *
144    * @return - an array converted from the current `Iterable`.
145    */
146   <<__Rx, __MaybeMutable, __PHPStdLib>>
147   public function toArray(): array;
148   /**
149    * Returns an `array` with the values from the current `Iterable`.
150    *
151    * The keys in the current `Iterable` are discarded and replaced with integer
152    * indices, starting with 0.
153    *
154    * @return - an `array` containing the values from the current `Iterable`.
155    */
156   <<__Rx, __MaybeMutable>>
157   public function toValuesArray(): varray;
158   /**
159    * Returns a `Vector` converted from the current `Iterable`.
160    *
161    * Any keys in the current `Iterable` are discarded and replaced with integer
162    * indices, starting with 0.
163    *
164    * @return - a `Vector` converted from the current `Iterable`.
165    */
166   <<__Rx, __MutableReturn, __MaybeMutable>>
167   /* HH_FIXME[4120]: While this violates our variance annotations, we are
168    * returning a copy of the underlying collection, so it is actually safe
169    * See #6853603. */
170   public function toVector(): Vector<Tv>;
171   /**
172    * Returns an immutable vector (`ImmVector`) converted from the current
173    * `Iterable`.
174    *
175    * Any keys in the current `Iterable` are discarded and replaced with integer
176    * indices, starting with 0.
177    *
178    * @return - an `ImmVector` converted from the current `Iterable`.
179    */
180   <<__Rx, __MaybeMutable>>
181   public function toImmVector(): ImmVector<Tv>;
182   /**
183    * Returns a `Set` converted from the current `Iterable`.
184    *
185    * Any keys in the current `Iterable` are discarded.
186    *
187    * @return - a `Set` converted from the current `Iterable`.
188    */
189   <<__Rx, __MutableReturn, __MaybeMutable>>
190   /* HH_FIXME[4120]: While this violates our variance annotations, we are
191    * returning a copy of the underlying collection, so it is actually safe.
192    * See #6853603. */
193   public function toSet(): Set<Tv>;
194   /**
195    * Returns an immutable set (`ImmSet`) converted from the current `Iterable`.
196    *
197    * Any keys in the current `Iterable` are discarded.
198    *
199    * @return - an `ImmSet` converted from the current `Iterable`.
200    */
201   <<__Rx, __MaybeMutable>>
202   public function toImmSet(): ImmSet<Tv>;
203   /**
204    * Returns a lazy, access elements only when needed view of the current
205    * `Iterable`.
206    *
207    * Normally, memory is allocated for all of the elements of the `Iterable`.
208    * With a lazy view, memory is allocated for an element only when needed or
209    * used in a calculation like in `map()` or `filter()`.
210    *
211    * @return - an `Iterable` representing the lazy view into the current
212    *           `Iterable`.
213    *
214    * @guide /hack/collections/examples
215    */
216   <<__Rx, __MutableReturn, __MaybeMutable>>
217   public function lazy(): namespace\Iterable<Tv>;
218   /**
219    * Returns an `Iterable` containing the current `Iterable`'s values.
220    *
221    * Any keys are discarded.
222    *
223    * @return An `Iterable` with the values of the current `Iterable`.
224    */
225   <<__Rx, __MutableReturn, __MaybeMutable>>
226   public function values(): namespace\Iterable<Tv>;
227   /**
228    * Returns an `Iterable` containing the values after an operation has been
229    * applied to each value in the current `Iterable`.
230    *
231    * Every value in the current `Iterable` is affected by a call to `map()`,
232    * unlike `filter()` where only values that meet a certain criteria are
233    * affected.
234    *
235    * @param $fn - The callback containing the operation to apply to the
236    *              `Iterable` values.
237    *
238    * @return - an `Iterable` containing the values after a user-specified
239    *           operation is applied.
240    *
241    * @guide /hack/collections/examples
242    */
243   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
244   public function map<Tu>(
245     <<__AtMostRxAsFunc>>(function(Tv): Tu) $fn,
246   ): namespace\Iterable<Tu>;
247   /**
248    * Returns an `Iterable` containing the values of the current `Iterable` that
249    * meet a supplied condition.
250    *
251    * Only values that meet a certain criteria are affected by a call to
252    * `filter()`, while all values are affected by a call to `map()`.
253    *
254    * @param $fn - The callback containing the condition to apply to the
255    *              `Itearble` values.
256    *
257    * @return - an `Iterable` containing the values after a user-specified
258    *           condition is applied.
259    *
260    * @guide /hack/collections/examples
261    */
262   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
263   public function filter(
264     <<__AtMostRxAsFunc>>(function(Tv): bool) $fn,
265   ): namespace\Iterable<Tv>;
266   /**s
267    *  Returns an `Iterable` where each element is a `Pair` that combines the
268    *  element of the current `Iterable` and the provided `Traversable`.
269    *
270    *  If the number of elements of the `Iterable` are not equal to the number of
271    *  elements in the `Traversable`, then only the combined elements up to and
272    *  including the final element of the one with the least number of elements
273    *  is included.
274    *
275    *  @param $traversable - The `Traversable` to use to combine with the
276    *                        elements of the current `Iterable`.
277    *
278    *  @return - The `Iterable` that combines the values of the current
279    *            `Itearable` with the provided `Traversable`.
280    */
281   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
282   public function zip<Tu>(
283     <<__OnlyRxIfImpl(namespace\Traversable::class)>> \Traversable<Tu> $traversable,
284   ): namespace\Iterable<Pair<Tv, Tu>>;
285   /**
286    * Returns an `Iterable` containing the first `n` values of the current
287    * `Iterable`.
288    *
289    * The returned `Iterable` will always be a proper subset of the current
290    * `Iterable`.
291    *
292    * `$n` is 1-based. So the first element is 1, the second 2, etc.
293    *
294    * @param $n - The last element that will be included in the returned
295    *             `Iterable`.
296    *
297    * @return - An `Iterable that is a proper subset of the current `Iterable`
298    *           up to `n` elements.
299    */
300   <<__Rx, __MutableReturn, __MaybeMutable>>
301   public function take(int $n): namespace\Iterable<Tv>;
302   /**
303    * Returns an `Iterable` containing the values of the current `Iterable` up
304    * to but not including the first value that produces `false` when passed to
305    * the specified callback.
306    *
307    * The returned `Iterable` will always be a proper subset of the current
308    * `Iterable`.
309    *
310    * @param $fn - The callback that is used to determine the stopping
311    *              condition.
312    *
313    * @return - An `Iterable` that is a proper subset of the current `Iterable`
314    *           up until the callback returns `false`.
315    */
316   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
317   public function takeWhile(
318     <<__AtMostRxAsFunc>>(function(Tv): bool) $fn,
319   ): namespace\Iterable<Tv>;
320   /**
321    * Returns an `Iterable` containing the values after the `n`-th element of the
322    * current `Iterable`.
323    *
324    * The returned `Iterable` will always be a proper subset of the current
325    * `Iterable`.
326    *
327    * `$n` is 1-based. So the first element is 1, the second 2, etc.
328    *
329    * @param $n - The last element to be skipped; the `$n+1` element will be
330    *             the first one in the returned `Iterable`.
331    *
332    * @return - An `Iterable` that is a proper subset of the current `Iterable`
333    *           containing values after the specified `n`-th element.
334    */
335   <<__Rx, __MutableReturn, __MaybeMutable>>
336   public function skip(int $n): namespace\Iterable<Tv>;
337   /**
338    * Returns an `Iterable` containing the values of the current `Iterable`
339    * starting after and including the first value that produces `true` when
340    * passed to the specified callback.
341    *
342    * The returned `Iterable` will always be a proper subset of the current
343    * `Iterable`.
344    *
345    * @param $fn - The callback used to determine the starting element for the
346    *              returned `Iterable`.
347    *
348    * @return - An `Iterable` that is a proper subset of the current `Iterable`
349    *           starting after the callback returns `true`.
350    */
351   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
352   public function skipWhile(
353     <<__AtMostRxAsFunc>>(function(Tv): bool) $fn,
354   ): namespace\Iterable<Tv>;
355   /**
356    * Returns a subset of the current `Iterable` starting from a given key up
357    * to, but not including, the element at the provided length from the
358    * starting key.
359    *
360    * `$start` is 0-based. `$len` is 1-based. So `slice(0, 2)` would return the
361    * elements at key 0 and 1.
362    *
363    * The returned `Iterable` will always be a proper subset of the current
364    * `Iterable`.
365    *
366    * @param $start - The starting key of the current `Iterable` to begin the
367    *                 returned `Iterable`.
368    * @param $len - The length of the returned `Iterable`.
369    *
370    * @return - An `Iterable` that is a proper subset of the current `Iterable`
371    *           starting at `$start` up to but not including the element
372    *           `$start + $len`.
373    */
374   <<__Rx, __MutableReturn, __MaybeMutable>>
375   public function slice(int $start, int $len): namespace\Iterable<Tv>;
376   /**
377    * Returns an `Iterable` that is the concatenation of the values of the
378    * current `Iterable` and the values of the provided `Traversable`.
379    *
380    * The values of the provided `Traversable` is concatenated to the end of the
381    * current `Iterable` to produce the returned `Iterable`.
382    *
383    * @param $traversable - The `Traversable` to concatenate to the current
384    *                       `Iterable`.
385    *
386    * @return - The concatenated `Iterable`.
387    *
388    * @guide /hack/generics/constraints
389    */
390   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
391   public function concat<Tu super Tv>(
392     <<__OnlyRxIfImpl(namespace\Traversable::class)>> \Traversable<Tu> $traversable,
393   ): namespace\Iterable<Tu>;
394   /**
395    * Returns the first value in the current `Iterable`.
396    *
397    * @return - The first value in the current `Iterable`, or `null` if the
398    *           current `Iterable` is empty.
399    */
400   <<__Rx, __MaybeMutable>>
401   public function firstValue(): ?Tv;
402   /**
403    * Returns the last value in the current `Iterable`.
404    *
405    * @return - The last value in the current `Iterable`, or `null` if the
406    *           current `Iterable` is empty.
407    */
408   <<__Rx, __MaybeMutable>>
409   public function lastValue(): ?Tv;
412 interface KeyedIterable<Tk, +Tv>
413   extends
414     namespace\KeyedTraversable<Tk, Tv>,
415     namespace\Iterable<Tv>,
416     \KeyedIterable<Tk, Tv> {
417   /**
418    * Returns an iterator that points to beginning of the current
419    * `KeyedIterable`.
420    *
421    * @return - A `KeyedIterator` that allows you to traverse the current
422    *           `KeyedIterable`.
423    */
424   <<__Rx, __MutableReturn, __MaybeMutable>>
425   public function getIterator(): namespace\KeyedIterator<Tk, Tv>;
426   /**
427    * Returns an `array` with the keys from the current `KeyedIterable`.
428    *
429    * @return - an `array` containing the values from the current
430    *           `KeyedIterable`.
431    */
432   <<__Rx, __MaybeMutable>>
433   public function toKeysArray(): varray;
434   /**
435    * Returns a `Map` based on the keys and values of the current
436    * `KeyedIterable`.
437    *
438    * @return - a `Map` that has the keys and associated values of the current
439    *           `KeyedIterable`.
440    */
441   <<__Rx, __MutableReturn, __MaybeMutable>>
442   /* HH_FIXME[4120]: While this violates our variance annotations, we are
443    * returning a copy of the underlying collection, so it is actually safe
444    * See #6853603. */
445   public function toMap(): \Map<Tk, Tv>;
446   /**
447    * Returns an immutable map (`ImmMap`) based on the keys and values of the
448    * current `KeyedIterable`.
449    *
450    * @return - an `ImmMap` that has the keys and associated values of the
451    *           current `KeyedIterable`.
452    */
453   <<__Rx, __MaybeMutable>> /* HH_FIXME[4110] T40426954 */
454   public function toImmMap(): \ImmMap<Tk, Tv>;
455   /**
456    * Returns a lazy, access elements only when needed view of the current
457    * `KeyedIterable`.
458    *
459    * Normally, memory is allocated for all of the elements of the
460    * `KeyedIterable`. With a lazy view, memory is allocated for an element only
461    * when needed or used in a calculation like in `map()` or `filter()`.
462    *
463    * @return - a `KeyedIterable` representing the lazy view into the current
464    *           `KeyedIterable`.
465    *
466    * @guide /hack/collections/examples
467    */
468   <<__Rx, __MutableReturn, __MaybeMutable>>
469   public function lazy(): namespace\KeyedIterable<Tk, Tv>;
470   /**
471    * Returns an `Iterable` containing the current `KeyedIterable`'s values.
472    *
473    * Any keys are discarded.
474    *
475    * @return An `Iterable` with the values of the current `KeyedIterable`.
476    */
477   <<__Rx, __MutableReturn, __MaybeMutable>>
478   public function values(): namespace\Iterable<Tv>;
479   /**
480    * Returns an `Iterable` containing the current `KeyedIterable`'s keys.
481    *
482    * Any values are discarded.
483    *
484    * @return An `Iterable` with the keys of the current `KeyedIterable`.
485    */
486   <<__Rx, __MutableReturn, __MaybeMutable>>
487   public function keys(): namespace\Iterable<Tk>;
488   /**
489    * Returns a `KeyedIterable` containing the values after an operation has been
490    * applied to each value in the current `KeyedIterable`.
491    *
492    * Every value in the current `KeyedIterable` is affected by a call to
493    * `map()`, unlike `filter()` where only values that meet a certain criteria
494    * are affected.
495    *
496    * @param $fn - The callback containing the operation to apply to the
497    *              `KeyedIterable` values.
498    *
499    * @return - a `KeyedIterable` containing the values after a user-specified
500    *           operation is applied.
501    *
502    * @guide /hack/collections/examples
503    */
504   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
505   public function map<Tu>(
506     <<__AtMostRxAsFunc>>(function(Tv): Tu) $fn,
507   ): namespace\KeyedIterable<Tk, Tu>;
508   /**
509    * Returns a `KeyedIterable` containing the values after an operation has
510    * been applied to each key and value in the current `KeyedIterable`.
511    *
512    * Every key and value in the current `KeyedIterable` is affected by a call to
513    * `mapWithKey()`, unlike `filterWithKey()` where only values that meet a
514    * certain criteria are affected.
515    *
516    * @param $fn - The callback containing the operation to apply to the
517    *              `KeyedIterable` keys and values.
518    *
519    * @return - a `KeyedIterable` containing the values after a user-specified
520    *           operation on the current `KeyedIterable`'s keys and values is
521    *           applied.
522    */
523   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
524   public function mapWithKey<Tu>(
525     <<__AtMostRxAsFunc>>(function(Tk, Tv): Tu) $fn,
526   ): namespace\KeyedIterable<Tk, Tu>;
527   /**
528    * Returns a `KeyedIterable` containing the values of the current
529    * `KeyedIterable` that meet a supplied condition.
530    *
531    * Only values that meet a certain criteria are affected by a call to
532    * `filter()`, while all values are affected by a call to `map()`.
533    *
534    * @param $fn - The callback containing the condition to apply to the
535    *              `KeyedItearble` values.
536    *
537    * @return - a `KeyedIterable` containing the values after a user-specified
538    *           condition is applied.
539    *
540    * @guide /hack/collections/examples
541    */
542   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
543   public function filter(
544     <<__AtMostRxAsFunc>>(function(Tv): bool) $fn,
545   ): namespace\KeyedIterable<Tk, Tv>;
546   /**
547    * Returns a `KeyedIterable` containing the values of the current
548    * `KeyedIterable` that meet a supplied condition applied to its keys and
549    * values.
550    *
551    * Only keys and values that meet a certain criteria are affected by a call to
552    * `filterWithKey()`, while all values are affected by a call to
553    * `mapWithKey()`.
554    *
555    * @param $fn - The callback containing the condition to apply to the
556    *              `KeyedIterable` keys and values.
557    *
558    * @return - a `KeyedIterable` containing the values after a user-specified
559    *           condition is applied to the keys and values of the current
560    *           `KeyedIterable`.
561    *
562    */
563   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
564   public function filterWithKey(
565     <<__AtMostRxAsFunc>>(function(Tk, Tv): bool) $fn,
566   ): namespace\KeyedIterable<Tk, Tv>;
567   /**
568    *  Returns a `KeyedIterable` where each element is a `Pair` that combines the
569    *  element of the current `KeyedIterable` and the provided `Traversable`.
570    *
571    *  If the number of elements of the `KeyedIterable` are not equal to the
572    *  number of elements in the `Traversable`, then only the combined elements
573    *  up to and including the final element of the one with the least number of
574    *  elements is included.
575    *
576    *  @param $traversable - The `Traversable` to use to combine with the
577    *                        elements of the current `KeyedIterable`.
578    *
579    *  @return - The `KeyedIterable` that combines the values of the current
580    *            `KeyedItearable` with the provided `Traversable`.
581    */
582   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
583   public function zip<Tu>(
584     <<__OnlyRxIfImpl(namespace\Traversable::class)>> \Traversable<Tu> $traversable,
585   ): namespace\KeyedIterable<Tk, Pair<Tv, Tu>>;
586   /**
587    * Returns a `KeyedIterable` containing the first `n` values of the current
588    * `KeyedIterable`.
589    *
590    * The returned `KeyedIterable` will always be a proper subset of the current
591    * `Iterable`.
592    *
593    * `$n` is 1-based. So the first element is 1, the second 2, etc.
594    *
595    * @param $n - The last element that will be included in the returned
596    *             `KeyedIterable`.
597    *
598    * @return - A `KeyedIterable that is a proper subset of the current
599    *           `KeyedIterable` up to `n` elements.
600    */
601   <<__Rx, __MutableReturn, __MaybeMutable>>
602   public function take(int $n): namespace\KeyedIterable<Tk, Tv>;
603   /**
604    * Returns a `KeyedIterable` containing the values of the current
605    * `KeyedIterable` up to but not including the first value that produces
606    * `false` when passed to the specified callback.
607    *
608    * The returned `KeyedIterable` will always be a proper subset of the current
609    * `KeyedIterable`.
610    *
611    * @param $fn - The callback that is used to determine the stopping
612    *              condition.
613    *
614    * @return - A `KeyedIterable` that is a proper subset of the current
615    *           `KeyedIterable` up until the callback returns `false`.
616    */
617   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
618   public function takeWhile(
619     <<__AtMostRxAsFunc>>(function(Tv): bool) $fn,
620   ): namespace\KeyedIterable<Tk, Tv>;
621   /**
622    * Returns a `KeyedIterable` containing the values after the `n`-th element
623    * of the current `KeyedIterable`.
624    *
625    * The returned `KeyedIterable` will always be a proper subset of the current
626    * `KeyedIterable`.
627    *
628    * `$n` is 1-based. So the first element is 1, the second 2, etc.
629    *
630    * @param $n - The last element to be skipped; the `$n+1` element will be
631    *             the first one in the returned `KeyedIterable`.
632    *
633    * @return - A `KeyedIterable` that is a proper subset of the current
634    *           `KeyedIterable`  containing values after the specified `n`-th
635    *           element.
636    */
637   <<__Rx, __MutableReturn, __MaybeMutable>>
638   public function skip(int $n): namespace\KeyedIterable<Tk, Tv>;
639   /**
640    * Returns a `KeyedIterable` containing the values of the current
641    * `KeyedIterable` starting after and including the first value that produces
642    * `true` when passed to the specified callback.
643    *
644    * The returned `KeyedIterable` will always be a proper subset of the current
645    * `KeyedIterable`.
646    *
647    * @param $fn - The callback used to determine the starting element for the
648    *              returned `KeyedIterable`.
649    *
650    * @return - A `KeyedIterable` that is a proper subset of the current
651    *           `KeyedIterable` starting after the callback returns `true`.
652    */
653   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
654   public function skipWhile(
655     <<__AtMostRxAsFunc>>(function(Tv): bool) $fn,
656   ): namespace\KeyedIterable<Tk, Tv>;
657   /**
658    * Returns a subset of the current `KeyedIterable` starting from a given key
659    * up to, but not including, the element at the provided length from the
660    * starting key.
661    *
662    * `$start` is 0-based. `$len` is 1-based. So `slice(0, 2)` would return the
663    * elements at key 0 and 1.
664    *
665    * The returned `KeyedIterable` will always be a proper subset of the current
666    * `KeyedIterable`.
667    *
668    * @param $start - The starting key of the current `KeyedIterable` to begin
669    *                 the returned `KeyedIterable`.
670    * @param $len - The length of the returned `KeyedIterable`.
671    *
672    * @return - A `KeyedIterable` that is a proper subset of the current
673    *           `KeyedIterable` starting at `$start` up to but not including the
674    *           element `$start + $len`.
675    */
676   <<__Rx, __MutableReturn, __MaybeMutable>>
677   public function slice(int $start, int $len): namespace\KeyedIterable<Tk, Tv>;
678   /**
679    * Returns an `Iterable` that is the concatenation of the values of the
680    * current `KeyedIterable` and the values of the provided `Traversable`.
681    *
682    * The values of the provided `Traversable` is concatenated to the end of the
683    * current `KeyedIterable` to produce the returned `Iterable`.
684    *
685    * @param $traversable - The `Traversable` to concatenate to the current
686    *                       `KeyedIterable`.
687    *
688    * @return - The concatenated `Iterable`.
689    *
690    * @guide /hack/generics/constraints
691    */
692   <<__Rx, __AtMostRxAsArgs, __MutableReturn, __MaybeMutable>>
693   public function concat<Tu super Tv>(
694     <<__OnlyRxIfImpl(namespace\Traversable::class)>> \Traversable<Tu> $traversable,
695   ): namespace\Iterable<Tu>;
696   /**
697    * Returns the first value in the current `KeyedIterable`.
698    *
699    * @return - The first value in the current `KeyedIterable`, or `null` if the
700    *           current `KeyedIterable` is empty.
701    */
702   <<__Rx, __MaybeMutable>>
703   public function firstValue(): ?Tv;
704   /**
705    * Returns the first key in the current `KeyedIterable`.
706    *
707    * @return - The first key in the current `KeyedIterable`, or `null` if the
708    *           current `KeyedIterable` is empty.
709    */
710   <<__Rx, __MaybeMutable>>
711   public function firstKey(): ?Tk;
712   /**
713    * Returns the last value in the current `KeyedIterable`.
714    *
715    * @return - The last value in the current `KeyedIterable`, or `null` if the
716    *           current `KeyedIterable` is empty.
717    */
718   <<__Rx, __MaybeMutable>>
719   public function lastValue(): ?Tv;
720   /**
721    * Returns the last key in the current `KeyedIterable`.
722    *
723    * @return - The last key in the current `KeyedIterable`, or `null` if the
724    *           current `KeyedIterable` is empty.
725    */
726   <<__Rx, __MaybeMutable>>
727   public function lastKey(): ?Tk;
730 interface Countable extends \Countable {
731   <<__Rx, __MaybeMutable>>
732   public function count(): int;