Make more type classes resolve, by matching rather than unification

Change 'apply' to 'match_apply' so that missing arguments are filled in by
matching on normal forms. This is safe (we think), since type class resolution
is merely looking for one instance which works, and this will make more
instances work.

Fixes #527