Works for a JavaScript FoldCalculator with runtime type-checking.