om: refactor internals of types header file formatter

- move boilerplate setup code into helper class so its shared between
  formatting methods.
- add initial support for external implementations of swap, inserter
  and equality. Commented out for now to validate refactoring in
  isolation.
om: implement external swap operator properly

- sml: copy across qualified name flattening code from C++ formatters
- om: handle all external methods and operators correctly