public static function generator(int $numberOfStages, callable $formStagesGeneratorFunction) : ActualStagedForm
    {
        $generator = $formStagesGeneratorFunction();

        if (!($generator instanceof \Generator)) {
            throw InvalidArgumentException::format(
                    'Invalid call to %s: first argument must be a generator function, function returned %s instead',
                    Debug::getType($generator)
            );
        }

        $builder                 = self::begin($generator->current());
        $numberOfDependentStages = $numberOfStages - 1;

        for ($i = 1; $i <= $numberOfDependentStages; $i++) {
            // TODO: Don't recreate generator for every form stage. (low-pri)
            $builder->then(function (array $data) use ($formStagesGeneratorFunction, $i) {
                /** @var \Generator $generator */
                $generator = $formStagesGeneratorFunction();
                for ($current = 1; $current <= $i; $current++) {
                    $generator->send($data);
                }

                return $generator->current();
            });
        }

        return $builder->build();
    }