This is available as SQL\ScalarFormat in the www repository.
SQL\ScalarFormat
namespace HH\Lib\SQL; interface ScalarFormat {...}
->format_d(?int $int): string
->format_f(?float $s): string
->format_s(?string $string): string