Cohomology on a category