Hello, I am facing an issue that I’m sure is very minor, but I cannot find anything in the documentation for either the package or Julia documentation. I’m hoping that someone here can help me out (without knowing too much about abstractalgebra.jl)
My main question is that I want to create a new “compound” struct from that assembles two types from the package AbstractAlgebra.jl. Consider the following
using AbstractAlgebra
FreeModule=AbstractAlgebra.Generic.FreeModule
Morphism=AbstractAlgebra.Generic.ModuleHomomorphism
mutable struct ChainComplex
modules::Array{FreeModule}
morphisms::Array{Morphism}
end
Now, apriori, the types FreeModule are already parametric. Indeed they take as input types such as BigInt, float{64} etc. I wanted to somehow include this in my definition, such as
FreeModule=AbstractAlgebra.Generic.FreeModule{T}
Morphism=AbstractAlgebra.Generic.ModuleHomomorphism{T}
but this appears to be nonsense in Julia, so I’m wondering how I can define this new compound type. When I try the first option above, and try to construct it, I get the error
M_1 = FreeModule(ZZ, 2)
M_2=FreeModule(ZZ,2)
f = ModuleHomomorphism(M_1, M_2, matrix(ZZ, 2, 2, [1, 2, 3, 4]))
ChainComplex([M_1,M_2],[f])
MethodError: Cannot
convert
an object of type
AbstractAlgebra.Generic.ModuleHomomorphism{BigInt} to an object of type
Array{AbstractAlgebra.Generic.ModuleHomomorphism,N} where N
which is a little bit jibberish, but I take it to mean that I declared this to be of a particular type without specifying BigInt, so once that specification comes in, it breaks my type.
If it is helpful, here is the return from the function typeof(M_1) and typeof(f) respectively:
AbstractAlgebra.Generic.FreeModule{BigInt}
AbstractAlgebra.Generic.ModuleHomomorphism{BigInt}
Is there any simple way to get the functionality that I want?