What you want is
mutable struct ChainComplex{F<:FreeModule,M<:ModuleHomorphism}
modules::Array{F}
morphisms::Array{M}
end
This makes your ChainComplex parametrized on the type of your module and morphism. It’s in the docs here Types · The Julia Language