function stringify_generic()

in src/PageSections/_Private/stringify_generic.hack [15:40]


function stringify_generic(
  string $ns,
  ScannedGeneric $generic,
): string {
  if ($generic->isCovariant()) {
    $base = '+';
  } else if ($generic->isContravariant()) {
    $base = '-';
  } else {
    $base = '';
  }
  $base .= $generic->getName();

  $constraints = $generic->getConstraints();
  if (C\is_empty($constraints)) {
    return $base;
  }

  return $constraints
    |> Vec\map(
      $$,
      $c ==> $c['relationship'].' '.stringify_typehint($ns, $c['type']),
    )
    |> Str\join($$, ' ')
    |> $base.' '.$$;
}