If it is intended that i be of class ZZ, M be of class A, and N be of class B, then the method can be installed with
cohomology(ZZ, A, B) := opts -> (i,M,N) -> ...
See also homology and ScriptedFunctor.