public static function forMap(array $map) : callable
    {
        return function ($index) use ($map) {
            Preconditions::checkArgument(
                array_key_exists($index, $map),
                "The given key '%s' does not exist in the map",
                $index
            );
            return $map[$index];
        };
    }