TODO squash up. $compile: support partialDigest as function and add tests