diff --git a/src/Groups.jl b/src/Groups.jl index 6a53c04..76d3752 100644 --- a/src/Groups.jl +++ b/src/Groups.jl @@ -14,25 +14,9 @@ using LinearAlgebra using Markdown -Base.one(G::Generic.PermGroup) = Generic.Perm(G.n) -Base.one(r::NCRingElem) = one(parent(r)) - -############################################################################### -# -# ParentType / ObjectType definition -# - include("types.jl") include("gsymbols.jl") - -function Base.one(G::Gr) where Gr <: AbstractFPGroup - El = elem_type(G) - id = El(eltype(El)[]) - id.parent = G - return id -end - -elem_type(G::Gr) where Gr <:AbstractFPGroup = elem_type(Gr) # fallback definition +include("fallbacks.jl") @doc doc""" diff --git a/src/fallbacks.jl b/src/fallbacks.jl new file mode 100644 index 0000000..bc1d1db --- /dev/null +++ b/src/fallbacks.jl @@ -0,0 +1,17 @@ +# workarounds +Base.one(G::Generic.PermGroup) = Generic.Perm(G.n) +Base.one(r::NCRingElem) = one(parent(r)) + +# fallback definitions +# note: the user should implement those on type, when possible +Base.eltype(w::GW) where GW<:GWord = eltype(GW) +AbstractAlgebra.elem_type(G::Gr) where Gr <:AbstractFPGroup = elem_type(Gr) + +AbstractAlgebra.parent_type(g::Gw) where Gw <:GWord = parent_type(parent(Gr)) + +function Base.one(G::Gr) where Gr <: AbstractFPGroup + El = elem_type(G) + id = El(eltype(El)[]) + id.parent = G + return id +end