Optimise the Typeable instance for type app a bit, and add a perf test

Test Plan: validate

Reviewers: simonpj, austin

Subscribers: simonmar, relrod

Differential Revision: https://phabricator.haskell.org/D20
accept T9181 output

Not sure if my patch changed this, but it looks reasonable.