A little refactoring

* Make isCFunEqCan_maybe return Maybe (TyCon, [Type])
* Add insertTM, deleteTM to TrieMap
Accommodate Derived constraints in two places (fix Trac #8129, #8134)

If we have
   class (F a ~ b) => C a b
then we can produce *derived* CFunEqCans.  These were not being
treated properly in two places:

a) in TcMType.zonkFlats (Trac #8134)
b) in TcSMonad.prepareInertsForImplications (Trac #8129)

This patch fixes both.
Optimise (case tagToEnum# x of ..) as in Trac #8317

See Note [Optimising tagToEnum#] in Simplify
Tidy up and refactor overflow checking for literals

It's much easier (and more efficient) to pattern match on
the HsOverLit than on the desugared version!