@informalsystems/quint
Version:
Core tool for the Quint specification language
41 lines (40 loc) • 1.34 kB
TypeScript
import { Maybe } from '@sweet-monads/maybe';
/** Add this at the end of a switch statement or if/then sequence to enforce exhaustiveness checking
*
* E.g.,
*
* ```
* switch (foo.bar) {
* case 'bax': ...
* case 'qux': ...
* default: unreachable(foo)
* }
* ```
* See https://stackoverflow.com/a/39419171 */
export declare function unreachable(object: never): never;
/** A wrapper around lodash zip that ensures all zipped elements are defined
*
* Raises `Error` if the arrays are not the same length
*/
export declare function zip<A, B>(a: A[], b: B[]): [A, B][];
/** `findMap(xs)` is `just(y)` if there is an `x` in `xs` for which `f(x)` is `just(y)`
* otherwise, it is `none`
*
* This is like `Array.prototype.find`, except that it works on any iterable and
* enables transforming the found value.
*
* Example:
*
* ```
* const result = findMap([1,2,3], (x) => x % 2 === 0 ? just(x) : none<int>())
* lodash.isEqual(result, just(2))
* ```
* */
export declare function findMap<X, Y>(xs: Iterable<X>, f: (x: X) => Maybe<Y>): Maybe<Y>;
/** Insert an item into an array sorted in ascending order by the given comparator.
*
* Important: The array must be sorted in ascending order.
*
* Complexity: O(log n)
*/
export declare function insertSorted<A>(array: A[], item: A, cmp: (a: A, b: A) => number): void;