Fold semantic checking over collection

Rather than using the fold to build a chain of semantic check functions.
This reduces the stack requirements for semantic checking.
Merge pull request #1765 from cleishm/semantic_check_optimization

Fold semantic checking over collections