More partial evaluation improvements

Propagate staticness into where blocks, make constraints on instances
static, and generalise over functions in types to make the partially
evaluated version as general as possible.
Merge pull request #1667 from edwinb/partial-eval

More partial evaluation improvements