Define type instances without wrapper function

This requires sorting binding groups by their immediate dependencies
(those not wrapped in function bodies).  This is not perfect, as
those functions may be evaluated immediately, but in any generated
instance declarations they are not.  All test cases passing, though
certain types of recursive definitions may not work (can't yet think of
any that weren't already broken by #365).