I'd like to propose changing the type signature of FunctionField from
FunctionField{T <: FieldElement}
to
FunctionField{T <: FieldElement, U <: PolyRingElem{T}}
mirroring the existing two-parameter design of RationalFunctionField{T, U}. This is a semi-breaking change, so I want to gauge interest before drafting a PR.
Motivation
Several fields of the FunctionField struct are currently typed existentially or abstractly, because the polynomial ring type U is not carried in the type signature, for example:
num::Poly{<:PolyRingElem{T}} — existential; concretely stored as Poly{U} for some U <: PolyRingElem{T}, but U does not appear in the struct's type parameters.
den::PolyRingElem{T} — PolyRingElem is abstract.
Or even
pol::Poly{RationalFunctionFieldElem{T, U}} where U <: PolyRingElem{T}
base_ring::RationalFunctionField{T, U} where U <: PolyRingElem{T}
essentially document that U ought to be a type parameter: RationalFunctionField already takes it, but FunctionField discards it.
Adding U as a second parameter would:
- Make every field of FunctionField concretely typed, improving type stability and codegen for downstream code.
- Bring FunctionField in line with
RationalFunctionField{T, U}, removing an asymmetry between two closely related types.
- Eliminate the where
U <: PolyRingElem{T} existentials currently needed in field declarations and method signatures.
Cost
I did a quick survey of downstream packages:
- Hecke.jl: roughly 100 references would need updating.
- Oscar.jl: a handful of references.
Further, FunctionField{T, U} would still allow FunctionField{T} usage most of the time, so this should not break the "usual" code.
Should I? Happy to prepare the PR for AbstractAlgebra and the corresponding follow-ups in Hecke and Oscar if this is welcome.
I'd like to propose changing the type signature of FunctionField from
to
mirroring the existing two-parameter design of
RationalFunctionField{T, U}. This is a semi-breaking change, so I want to gauge interest before drafting a PR.Motivation
Several fields of the FunctionField struct are currently typed existentially or abstractly, because the polynomial ring type U is not carried in the type signature, for example:
num::Poly{<:PolyRingElem{T}}— existential; concretely stored asPoly{U}for someU <: PolyRingElem{T}, butUdoes not appear in the struct's type parameters.den::PolyRingElem{T}— PolyRingElem is abstract.Or even
essentially document that
Uought to be a type parameter:RationalFunctionFieldalready takes it, butFunctionFielddiscards it.Adding
Uas a second parameter would:RationalFunctionField{T, U}, removing an asymmetry between two closely related types.U <: PolyRingElem{T}existentials currently needed in field declarations and method signatures.Cost
I did a quick survey of downstream packages:
Further,
FunctionField{T, U}would still allowFunctionField{T}usage most of the time, so this should not break the "usual" code.Should I? Happy to prepare the PR for AbstractAlgebra and the corresponding follow-ups in Hecke and Oscar if this is welcome.